- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @\"Cell2\";
UILabe
It sounds as if you are using iOS 5 (or later) and Storyboards.
Under iOS 5 (or later), if you are using Storyboards and the TableView Controller, the dequeueReusableCellWithIdentifier:
method is guaranteed to return a cell (provided that you have defined a cell with the given identifier in the Storyboard).
If this is the case, the solution is to fully create the custom table cell in the Storyboard. Go to your Table View in your Storyboard, select Content:Dynamic Prototypes
and make the Prototype Cells:1
. Now layout your cell graphically to be exactly what you want. Now click on the cell and set Identifier:Cell2
. You will now not need to create the label at runtime or check if it is nil. Full details including how to reference the labels you have setup are in the iOS 5 Release Notes (link below) or in many tutorials on the web.
See the iOS 5 Release Notes section Configuring Table Views