【发布时间】:2011-10-19 07:56:35
【问题描述】:
-(void) reload{
[self.tableViewa reloadData];
}
-(void) viewWillAppear:(BOOL)animated{
[self.tableViewa reloadData];
[cachedProperties setTags:nil];
self.tabBarController.navigationItem.rightBarButtonItem =nil;
self.tabBarController.navigationItem.leftBarButtonItem =nil;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [[cachedProperties getTags] count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CheckMarkCellIdentifier = @"CheckMarkCellIdentifier";
UITableViewCell * cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CheckMarkCellIdentifier] autorelease];
NSUInteger row = [indexPath row];
if([[[cachedProperties getTags] objectAtIndex:row] isNotEmpty]){
cell.textLabel.text = [[cachedProperties getTags]objectAtIndex:row];
cell.accessoryType= UITableViewCellAccessoryDetailDisclosureButton;
}
return cell;
}
使用此方法,当 viewWillAppear 有一个代码 [self.tableviewa reloadData] 并会调用 numberOfRowsInSection,但是当我调用具有 [self.tableviewa reloadData] 的方法 Reload 时,不会调用函数 numberOfRowInSection.. 如何是真的吗?这个问题有什么原因吗?
因为在第一次调用 viewWillAppear 时,[cachedProperties setTags:nil] 将设置标签并将调用 -(void) reload{
[self.tableViewa reloadData];
} 或 [thatClass.tableViewa reloadData] 我需要使 tableView 不为空。为什么tableView没有reloadData?
【问题讨论】:
-
numberOfSectionsInTableView:方法呢?您是否检查过它返回的值不是0?
标签: xcode uitableview tableview