Hi all, please bear with me as I am new to iOS programming. I have a tableview inside one of my Viewcontrollers, but none of my tableview methods are being called. The table view is also properly linked to datasource and delegate.
For example, below I have many methods that change the size and color/contents of the tableview, but when I run the application, nothing happens. The tableview just looks like the default size/color.
Any input would be helpful.
For example, below I have many methods that change the size and color/contents of the tableview, but when I run the application, nothing happens. The tableview just looks like the default size/color.
Any input would be helpful.
Code:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
//tableview cell height
return 60;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfSectionsInTableView:(NSInteger)section {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [storyList count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = (UITableViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
//---------- CELL BACKGROUND IMAGE -----------------------------
UIImageView *imageView = [[UIImageView alloc] initWithFrame:cell.frame];
UIImage *image = [UIImage imageNamed:@"LightGrey.png"];
imageView.image = image;
cell.backgroundView = imageView;
[[cell textLabel] setBackgroundColor:[UIColor clearColor]];
[[cell detailTextLabel] setBackgroundColor:[UIColor clearColor]];
cell.textLabel.text = [storyList objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [storyListAuthor objectAtIndex:indexPath.row];
return cell;
[tableView reloadData];
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
DetailViewController *detail = [self.storyboard instantiateViewControllerWithIdentifier:@"detail"];
detail.state = [datasource objectAtIndex:indexPath.row];
detail.capital = [storyListAuthor objectForKey:detail.state];
[self.navigationController pushViewController:detail animated:YES];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}