I really need help with filling in data in a Table View, where my Table View resides in a Navigation Bar, where the Navigation bar lies in a Tab Bar. After hours of trying add at least 5 data in my Navigation Bar, but it was never able to fill in my Navigation Bar. This was the code I’ve been using, which is supposed to be the right code: (this code is written before - (void)dealloc:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 5;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell.
cell.textLabel.text = @"Some value";
return cell;
}
In addition, I tried linked up the dataSource and delegate Outlets to the File Owners, but when I ran the app, when I clicked the Tab Bar Item where my table view is supposed to show my 5 data, it stopped and crashed my app. When I disconnected the dataSource and delegate from File Owners and ran the app again, the Table View is empty in the Navigation Bar with no data filled in, just empty blanks.
So I don’t know what else is going wrong here, either I have to link the dataSource and delegate again, which will cause the app to crash again or someone thinks my code is incorrect or is there problems when I insert a Table View in a Navigation Bar and inserting Navigation Bar into a Tab Bar?
Anyone please help me, thanks
Make sure you set the identity of the File’s Owner to be a subclass of
UITableViewControllerthat contains the code you posted above. You can view the identity by selecting File’s Owner in the document window and using the Identity tab (4th tab) in the Inspector Panel.