simusid
simusid

Reputation: 1904

iPad App - how to change UITableViewCell style?

Again I'm moving from Xcode 3 to 4 and finding that some things are different. I'm writing a splitview iPad app and working from all the code that was generated for me. In the master view I want to customize the UITableViewCell to use the UITableViewCellStyleSubtitle style. In the past that was simple and I knew it was done within tableView:cellForRowAtIndexPath:.

In the new template code there is no [[UITableViewCell alloc] init....] there is only

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];

so I can't modify the style here. I looked in the storyboard and found the cell but cannot seem to change the property there either.

In short, I can't find where the UITableViewCells are alloc/init'ed so that I can make my change. Where is this done in Xcode 4?

Upvotes: 0

Views: 1195

Answers (2)

rickster
rickster

Reputation: 126127

If you're using the storyboard-based template, the cell is created by the storyboard, so you need to configure it in the storyboard in IB. If you haven't found that, it's here:

enter image description here

Select the cell, and it'll be in the attributes inspector. While you're there you might want to set a reuse identifier you can use in tableView:cellForRowAtIndexPath:.

(You can also use IB to change the font or other properties of the cell's textLabel and detailTextLabel and set accessory styles like you would have before in tableView:cellForRowAtIndexPath:.)

Upvotes: 2

psalvaggio
psalvaggio

Reputation: 181

UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];

This is still done in cellForRowAtIndexPath

Upvotes: -1

Related Questions