Take the 2-minute tour ×

I am doing a newspaper application.

I want a tableview's first cell to consists of 2 views of different sizes and from 2nd cell they want 3 view's of same size in each cell and action for every cell's view

! http://imgh.us/custom_cell.png

share|improve this question
What have you done so far that doesn't work? –  XCode Monkey Aug 25 '13 at 12:38
i have done it in scroll view, creating views in for loop , it works fine for me , but wen doing parsing evrytime, it creates the view in the for loop so it takes long time to display the page..... @XCode Monkey –  KSR Aug 25 '13 at 12:47
add comment

1 Answer

Just design the UITableViewCell in a NIB file and create the relative .h and .m files, let's say:


In MyCell.xib place all the subviews you desire, and set the class of the main Cell Object to MyCell (rather than the standard UITableViewCell).
Then you can set some IBOutlets in the code and link them to the subviews in the XIB. You can also place some IBActions in the custom view class, although it is bad practice and you should really have your logic in controllers. The MyCell.m file should be used for initialization logic and animations.

Finally, in your TableViewController hook it all together:

#import "MyCell.h"

#define k_CELL_ID @"k_CELL_ID"
#define CELL_HEIGHT 80.0f

@implementation MyTableViewController

- (void)viewDidLoad
    [super viewDidLoad];

    UITableView *theTableView = (UITableView*)self.view;
    [theTableView registerNib:cellNib forCellReuseIdentifier:k_CELL_ID];

    theTableView.rowHeight = CELL_HEIGHT; //not sure if this is ok in iOS 7

    MyCell *cell = [tableView dequeueReusableCellWithIdentifier:k_CELL_ID];
    if (cell == nil)
        NSLog(@"cell is nil! WTF??");

    id someData = //retrieve customization data
    [cell setupWithCustomData:someData];

    return cell;

share|improve this answer
just really offtopic: why he dont use IB: blog.teamtreehouse.com/why-i-dont-use-interface-builder –  CarlJ Aug 27 '13 at 14:07
add comment

Your Answer


