UITableView не показывает никаких данных - PullRequest
1 голос
/ 01 сентября 2011

Я создаю приложение, в котором я использую приложение на основе представления.
Мой первый взгляд - это простой класс контроллеров представления. в этом представлении есть несколько кнопок.
Когда я нажимаю кнопку, я хочу просмотреть таблицу.
поэтому я беру UITableViewController подкласс.

что я за монета

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSBundle *bundle =[NSBundle mainBundle];
    NSString *path = [bundle pathForResource:@"cases" ofType:@"plist"];
    listfile = [[NSArray alloc ] initWithContentsOfFile:path];
   [self loadView];

}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

// Configure the cell...
NSArray *temp = [listfile objectAtIndex:indexPath.row];
cell.textLabel.text = [temp objectAtIndex:0];
   NSLog(@"Count : %@" , cell.textLabel.text);
return cell;
}

Но я не вижу никаких данных. это показывает только пустую таблицу. Я делаю что-то не так ??

Спасибо.

1 Ответ

8 голосов
/ 01 сентября 2011

Вы должны реализовать следующие методы в вашем UITableViewController:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in section. 
    return [caselist count];
}

И

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 1;
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...