indexpath.row is showing less number of rows
I have created an tableview with an array. There are 7 items in my array.
But in cellForRowAtIndexPath method i'm unable to get indexpath.row == 6.
What could be the reason. Code is below for this.
-(void)viewDidLoad
{
[super viewDidLoad];
self.menu = [NSArray
arrayWithObjects:@"Home",@"ansCategory",@"askQue",@"myQue",@"likedQue",
@"topQue", @"topUser",nil];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
// NSLog(@"count::::::%d",self.menu.count);
return self.menu.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = @"Cell";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:cellIdentifier];
NSLog(@"rows:%@",indexPath);
NSLog(@"row:%@",[self.menu objectAtIndex:indexPath.row]);
}
return cell;
}
No comments:
Post a Comment