views:

314

answers:

3

Steps to reproduce:
1. Create a Tab Bar Application called "TestApp"
2. Add new file, a UIViewController subclass with a XIB user interface called "Table"
3. Open up MainWindows.xib, click on the Second tab bar item and in Inspector change the NIB Name from "SecondView" to "Table". Save and close.
4. Open up Table.xib and drag a TableView on top of the view. Now link the dataSource and delegate outlets of the TableView to the Table.xib File's Owner.
5. Add the following code to Table.m:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
NSLog(@"Returning num sections");
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(@"Returning num rows");
return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"Trying to return cell");

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
cell.text = @"Hello";
NSLog(@"Returning cell");
return cell;
}

6.Run the application and select the Second tab bar item.

If I start with a View-based application, add a TableView to it, link the outlets to the File's owner and add that piece of code it all works just fine. What am I doing wrong ? Why is the application crashing ?

A: 

I have the same problem. Please help!

Darko Hebrang
A: 

In Interface Builder, after you've updated the NIB Name to Table, click on the Identity tab of the inspector (the last tab). Then updated the Class Identity to 'Table'.

Chris Gummer
A: 

i have the same problem! please help me!

phongnt