我正在使用这种方式获取数据,我希望我应该在节标题中显示日期 和appDelegate.book1数组中的行中的事件位置。当这个绳索首先运行然后在第一部分中它必须在一个部分中显示7行,并且相同,但是我没有被要求
NSArray *activitiesArray;
for (int j=0;j<10; j++) {
NSDictionary *dictOne = [results objectAtIndex:j];
NSLog(@"%@ - %@", [dictOne objectForKey:@"date"]);
Date *aDate = [[Date alloc] initWithDictionary:[results objectAtIndex:j]];
[appDelegate.dates addObject:aDate];
[aDate release];
activitiesArray = [dictOne objectForKey:@"events"];
for (int i=0; i<[activitiesArray count]; i++) {
int testcount =[activitiesArray count];
NSDictionary *dictTwo = [activitiesArray objectAtIndex:i];
NSDictionary *eventDict=[dictTwo objectForKey:@"event"];
// NSLog(@"%@ - %@", [dictOne objectForKey:@"date"]);
// NSLog(@"%@ - %@", [dictTwo objectForKey:@"affectedDate"]);
// NSLog(@"%@ - %@", [eventDict objectForKey:@"location"]);
NSInteger*date=[dictTwo objectForKey:@"affectedDate"];
NSInteger*affectedDate=[dictTwo objectForKey:@"affectedDate"];
NSString*appId =[eventDict objectForKey:@"appId"];
NSString*eventId=[eventDict objectForKey:@"eventId"];
NSString*location=[eventDict objectForKey:@"location"];
NSString*municipality=[eventDict objectForKey:@"municipality"];
NSString*title=[eventDict objectForKey:@"title"];
Book1 *aBook=[[Book1 alloc] initWithDate:date affectedDate:affectedDate location:location municipality:municipality title:title];
[appDelegate.books1 addObject:aBook];
int count=[appDelegate.books1 count];
}
}
这是appDelegate.book1计数的NSLog 整数num的值为1 2011-08-09 12:40:31.731 FVN [2409:207]整数num的值是2 2011-08-09 12:40:31.731 FVN [2409:207]整数num的值为3 2011-08-09 12:40:31.731 FVN [2409:207]整数num的值为4 2011-08-09 12:40:31.732 FVN [2409:207]整数num的值为5 2011-08-09 12:40:31.732 FVN [2409:207]整数num的值为6 2011-08-09 12:40:31.733 FVN [2409:207]整数num的值是7
所以像这个数组一样,我的表视图应该在第一部分中显示7个项目,因为它们是顺序的,所以如何执行此操作
答案 0 :(得分:0)
我认为您在Table视图控制器子类中寻找以下两个委托方法。
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2; //return the actual number of sections you want
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
if(section == 0)
return 7; //actually return your array1's count
if(section == 1)
return 9; //actually return your array2's count
}
HTH,
阿克沙伊