[英]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.