I have created Windows-based application, added UITabBarController. As elements of view in every tab i added navigation controller (from objects panel). Then i have created a subclass of UITableViewController with xib file. And changed (in properties) the view of UINavigationController i added before into my subclass. After this i changed the next lines.
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = NSLocalizedString(@"devices", @"my devices");
NSMutableArray *array = [[NSArray alloc] initWithObjects: @"Kitchen", @"Door 1", @"Door 2", nil];
self.devicesArray = array; // it's a private variable
[array release];
NSLog(@"%@", [self.devicesArray objectAtIndex:0]);
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.devicesArray count];
}
- (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...
NSInteger row = [indexPath row];
cell.textLabel.text = [devicesArray objectAtIndex:row];
return cell;
}
But i can see only clean UITableView. Without the text. But NSLog outputs text in viewDidLod properly
检查是否在xib文件中设置了委托和数据源插座连接。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.