【发布时间】:2013-07-04 11:27:22
【问题描述】:
我调试 DataArray 已更改,但在 UITableView 上仍然没有显示从 DataArray 获取的新数据。
这是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = [NSString stringWithFormat:@"%d,%d",indexPath.section,indexPath.row];
UITableViewCell *cell = [_tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
UILabel *FileNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 100, 30)];
FileNameLabel.backgroundColor = [UIColor clearColor];
FileNameLabel.font = [UIFont fontWithName:@"Helvetica" size:16];
FileNameLabel.font = [UIFont boldSystemFontOfSize:16];
FileNameLabel.textColor = [UIColor blackColor];
NSLog(@"File Temp 4 array: %@", temp);
FileNameLabel.text =[temp objectAtIndex:indexPath.row];
[cell.contentView addSubview: FileNameLabel];
[FileNameLabel release];
}
return cell;
}
在ViewWillAppear 中作用update()
-(void) update
{
if([FileCompletedArray count] != [temp count])
{
temp = [FileCompletedArray mutableCopy];
NSLog(@"File Temp 1 array: %@", temp);
[_tableView reloadData];
NSLog(@"File Temp 2 array: %@", temp);
}
}
你有解决办法吗?
【问题讨论】:
-
每行中命名约定被多次破坏的代码很难阅读。
标签: ios objective-c iphone uitableview cocoa-touch