[英]UITableView doesn't show elements
我创建了基于Windows的应用程序,并添加了UITabBarController。 作为每个选项卡中的视图元素,我添加了导航控制器(从对象面板)。 然后,我用xib文件创建了UITableViewController的子类。 并更改了(在属性中)我之前添加到子类中的UINavigationController的视图。 之后,我更改了下几行。
- (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;
}
但是我只能看到干净的UITableView。 没有文字。 但是NSLog在viewDidLod中正确输出文本
检查是否在xib文件中设置了委托和数据源插座连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.