나는 타이머에 의해 불리는 방법으로 업데이트하고 싶은 UITableView를 가지고있다. 내가 지금 가지고있는 것은 :계속해서 테이블 뷰를 채우는 것
-(void) populateTable {
NSLog(@"done");
NSArray *array = [[NSArray alloc] initWithObjects:@"ob 1",@"ob 2",@"ob 3",nil];
self.listData = array;
[array release];
}
- (void)viewDidLoad {
[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(populateTable) userInfo:nil repeats:YES];
[super viewDidLoad];
}
#pragma mark -
#pragma mark Table View Data Source Methods
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
return [self.listData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:SimpleTableIdentifier] autorelease];
}
NSUInteger row = [indexPath row];
cell.textLabel.text = [listData objectAtIndex:row];
return cell;
}
내가 viewDidLoad
로 배열 self.listData = array
를 넣으면 작동하지만, 반복되지 않습니다. 내 방법 populateTable
이 호출되고 있지만 테이블에 실제로 아무것도 넣지는 않습니다. 이것은 내가 처음으로 UITableView를 사용하기 때문에 그들이 어떻게 작동하는지 너무 많이 알지 못합니다. 튜토리얼을 따라이 작업을 많이 수행했습니다. 메소드를 사용하여 데이터를 채우는 방법은 무엇입니까?
안녕을 포함하여 현재 상태를 지 웁니다 a/25604378/294884 누군가 도움이되기를 바랍니다 – Fattie