0
리사이클 버튼으로 인해 리사이클 버튼이 전혀 선택되지 않았기 때문에 큰 문제가 발생했습니다! 버튼에 태그를 지정했지만 올바른 버튼을 감지하지 못했습니다. 도와주세요! 나는 며칠 동안이 일에 매달 렸습니다. 그렇지 않은 경우 태깅 이외의 다른 더 나은 솔루션을 자유롭게 권유하십시오.iITableViewCell의 iOS 동적 버튼 태그가 테이블의 올바른 행을 감지하지 못합니다.
"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;
} 지금과 같은 방법
: I는 다음과 같습니다있는 NSDictionary를 통해 섹션과 행 구문 분석
감사합니다. muc h!
for (int a = 0; a < myArray.count; a++){
NSMutableDictionary *mDict = [myArray objectAtIndex:a];
NSNumber *myIndex = [NSNumber numberWithInt:a];
[mDict setValue:myIndex forKey:@"index"];
NSLog(@"added index: %@", myArray);
}
self.myArray = myArray;
올바른 항목을 감지 할 수 있도록 내가 내 버튼의 태그를 설정하기 전에 :
이 방법에'dataSource'을 만들지 마십시오 ** viewDidLoad' 또는'viewWillAppear'에 init **을 한 번 ** ** 채 웁니다. 그 외, Renew 버튼을 처리하는 코드는 무엇입니까? –
@Phillip 인터넷 연결을 확인하는 메소드를 시작하고 button.tag에서 갱신 횟수를 확인합니다 (최대 갱신 횟수는 3 회) NSString * noRenewal = [[myArray objectAtIndex : button.tag] objectForKey : @ "noOfRenewal"]; –
동일한 채우기를 사용하여 셀을 채우는 데 사용하는 갱신을 검색해야합니다. 다시 한번,'dataSource'를 한 번 생성 한 다음 section/row를 사용하여'myArray'보다는 두 가지 용도로 정보를 얻는 것이 좋습니다. 그렇지 않으면 태그 값이 행이 아닌 배열에 대한 색인이어야합니다. –