リサイクルのために更新ボタンが選択されている行をまったく検出しないため、現在大きな問題が発生しています。ボタンにタグを付けようとしましたが、正しいボタンも検出されません。助けてください!私はこれに数日間立ち往生しています。そうでない場合は、タグ付け以外のより良い解決策をお勧めします。NSDictionaryを介してセクションと行を解析します。これは次のようになります。
"15/08/2012" = (
{
BIBNo = 290408;
date = "15/08/2012";
itemSequence = 000010;
name = "Sams teach yourself iPhone application development in 24 hours / John Ray.";
noOfRenewal = 3;
number = 000290408;
status = "Normal Loan";
time = "24:00";
type = Loans;
}
);
"16/08/2012" = (
{
BIBNo = 187883;
date = "16/08/2012";
itemSequence = 000010;
name = "Positive thinking / Susan Quilliam.";
noOfRenewal = 3;
number = 000187899;
status = "Normal Loan";
time = "24:00";
type = Loans;
},
{
BIBNo = 161816;
date = "16/08/2012";
itemSequence = 000010;
name = "Malaysian Q & As / compiled by Survey & Interview Department ; illustrations by Exodus.";
noOfRenewal = 1;
number = 000161817;
status = "Normal Loan";
time = "24:00";
type = Loans;
}
);
"17/08/2012" = (
{
BIBNo = 187882;
date = "17/08/2012";
itemSequence = 000010;
name = "Increasing confidence / Philippa Davies.";
noOfRenewal = 1;
number = 000187907;
status = "Normal Loan";
time = "24:00";
type = Loans;
},
{
BIBNo = 244441;
date = "17/08/2012";
itemSequence = 000010;
name = "Coach : lessons on the game of life / Michael Lewis.";
noOfRenewal = 2;
number = 000244441;
status = "Normal Loan";
time = "24:00";
type = Loans;
},
{
BIBNo = 291054;
date = "17/08/2012";
itemSequence = 000010;
name = "iPhone application development for IOS 4 / Duncan Campbell.";
noOfRenewal = 3;
number = 000291054;
status = "Normal Loan";
time = "24:00";
type = Loans;
}
);
}
の私のコードcellForRowAtIndexPath
:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UserCustomCell *cell = (UserCustomCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.bookTitle.frame = CGRectMake(12, 0, 550, 40);
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"UserCustomCell" owner:self options:nil];
cell = userCustomCell;
self.userCustomCell = nil;
}
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
cell.bookTitle.frame = CGRectMake(12, 0, 550, 40);
cell.renewButton.frame = CGRectMake(600, 14, 68, 24);
}
[cell.renewButton useBlackActionSheetStyle];
dataSource = [[NSMutableDictionary alloc] init]; // This would need to be an ivar
for (NSDictionary *rawItem in myArray) {
NSString *date = [rawItem objectForKey:@"date"]; // Store in the dictionary using the data as the key
NSMutableArray *section = [dataSource objectForKey:date]; // Grab the section that corresponds to the date
if (!section) { // If there is no section then create one and add it to the dataSource
section = [[NSMutableArray alloc] init];
[dataSource setObject:section forKey:date];
}
[section addObject:rawItem]; // add your object
}
self.dataSource = dataSource;
NSLog(@"Data Source Dictionary: %@", dataSource);
NSArray *sections =[[dataSource allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
NSString *sectionTitle = [sections objectAtIndex:indexPath.section];
NSArray *items = [dataSource objectForKey:sectionTitle];
NSDictionary *dict = [items objectAtIndex:indexPath.row];
cell.bookTitle.text = [dict objectForKey:@"name"];
cell.detail.text = [NSString stringWithFormat:@"Due Date: %@ Due Time: %@",
[dict objectForKey:@"date"], [dict objectForKey:@"time"]];
cell.renewButton.tag = indexPath.row;
return cell;
}
今の様子:
どうもありがとう!