Reputation: 1457
I have setup three prototype cells as shown in screenshot below.However when I run the app , all the elements like labels and imageView doesn't show up properly.I have designed these things in prototype cells in storyboard , using dragging and dropping appropriate elements at the desired positions and haven't added any code such as heightForRow
.I have also checked Simulated Metrics which is set for Retina 4 inch.What am I doing wrong?
Designed as below.
And the following displays on the simulator.
Upvotes: 0
Views: 182
Reputation: 17595
Implement heightForRowAtIndexPath:
correctly and also check your delegate config(tblview.delegate = self)
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0)
return row1Height;
else if(...).
.
.
.
else
return defaultHeight;
}
Upvotes: 2
Reputation: 280
Try like this:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier1 = @"Cell1";
static NSString *CellIdentifier2 = @"Cell2";
static NSString *CellIdentifier3 = @"Cell3";
// Configure the cell...
if([indexPath row] == 0)
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1 forIndexPath:indexPath];
//cell.textlabel = @"YourText";
//
}
if([indexPath row] == 1)
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2 forIndexPath:indexPath];
//cell.textlabel = @"YourText";
//
}
if([indexPath row] == 2)
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier3 forIndexPath:indexPath];
//cell.textlabel = @"YourText";
//
}
Upvotes: -1
Reputation: 2270
Can you return the appropriate row size in the delegate method?
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return yourHeight;
}
Upvotes: 0