UITableView not showing any data
I am making an app in which i am using view based application.
My first view is a simple view controller class. there are some buttons in that view. When i tap button , i want tableview. so i am taking UITableView开发者_开发问答Controller subclass.what i am coin is
- (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;
}
But, i can't see any data . it shows blank table only. I am doing anything wrong??
Thank you.
You should implement following methods in your UITableViewController
:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in section.
return [caselist count];
}
And
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
精彩评论