Search code examples
iphoneuitableviewios5cell

Static cell does not display


I am referring a tutorial from raywenderlich ,i have done all it said but still my static cell does not display,any help regarding this....

But it can add data in my tableview which its connected.

This is screen in my storyboard.

enter image description here

And this is my emulator screen.

enter image description here

UPDATED 1

when i have change code like this than section will display but still row does not display.

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{

    // Return the number of sections.
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    // Return the number of rows in the section.
    return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    // Configure the cell...

    return cell;
}

enter image description here

And in The PlayerDetailVewController.h delegate,

    @class Player;
    @class PlayerDetailsViewController;

    @protocol PlayerDetailsViewControllerDelegate <NSObject>
    - (void)playerDetailsViewControllerDidCancel:
    (PlayerDetailsViewController *)controller;
    //- (void)playerDetailsViewControllerDidSave:
    //(PlayerDetailsViewController *)controller;
    - (void)playerDetailsViewController:
    (PlayerDetailsViewController *)controller 
                           didAddPlayer:(Player *)player;
    @end
@interface PlayerDetailsViewController : UITableViewController

@property (nonatomic, weak) id <PlayerDetailsViewControllerDelegate> delegate;

UPDATED 2

when i change row in section return 1 like this,

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{

    // Return the number of sections.
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    // Return the number of rows in the section.
    return 1;
}

and show error like this

2012-10-04 13:54:46.152 Rating[514:f803] *** Assertion failure in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:], /SourceCache/UIKit_Sim/UIKit-1914.84/UITableView.m:6061
2012-10-04 13:54:46.154 Rating[514:f803] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
*** First throw call stack:
(0x13cf022 0x1560cd6 0x1377a48 0x9b02cb 0xb3d28 0xb43ce 0x9fcbd 0xae6f1 0x57d21 0x13d0e42 0x1d87679 0x1d91579 0x1d164f7 0x1d183f6 0x1d17ad0 0x13a399e 0x133a640 0x13064c6 0x1305d84 0x1305c9b 0x12b87d8 0x12b888a 0x19626 0x29cd 0x2935)
terminate called throwing an exception(lldb) 

Solution

  • Your log said that

    'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'

    that means cellforrowatindexpath must not return any value. delete this method,

    (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath