Iโve been searching Google all day, but I just canโt find a solution for this.
I am trying to implement a table view with custom cells in my iOS application. I use custom cells displaying different images and labels. Everything is working fine, except that the cells are too large to represent the table. I know that I need to implement the heightForRowAtIndexPath method, but it is never called.
I tried setting the delegate for TableView in the nib file and in ShowPostsViewController in the code, but nothing helps. I expect the problem is probably that dataSource is installed but not a delegate. However, I do not understand why.
Every solution that I have found so far suggests that the delegate is not installed correctly. However, I am sure that this is in my case ?! I am grateful for any help. Here is my code:
ShowPostsViewController.h
@interface ShowPostsViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> @property (nonatomic, strong) IBOutlet UITableView *postsTableView; @end
And ShowPostsViewController.m
@implementation ShowPostsViewController @synthesize postsTableView; - (void)viewDidLoad { [super viewDidLoad]; self.postsTableView.delegate = self; self.postsTableView.dataSource = self; NSLog(@"Delegate set"); [postsTableView beginUpdates]; NSMutableArray *tempArray = [[NSMutableArray alloc] init]; for(int i=0; i<8; i++){ [tempArray addObject: [NSIndexPath indexPathForRow:i inSection:0]]; } [postsTableView insertRowsAtIndexPaths:tempArray withRowAnimation:UITableViewRowAnimationAutomatic]; NSLog(@"Updates Called"); [postsTableView endUpdates]; [postsTableView reloadData]; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 8; }
I also have a tableView associated with ShowPostsViewController in Interface Builder. 
Thank you all for your great support.
source share