简体   繁体   English

UITableView不显示元素

[英]UITableView doesn't show elements

I have created Windows-based application, added UITabBarController. 我创建了基于Windows的应用程序,并添加了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. 然后,我用xib文件创建了UITableViewController的子类。 And changed (in properties) the view of UINavigationController i added before into my subclass. 并更改了(在属性中)我之前添加到子类中的UINavigationController的视图。 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. 但是我只能看到干净的UITableView。 Without the text. 没有文字。 But NSLog outputs text in viewDidLod properly 但是NSLog在viewDidLod中正确输出文本

检查是否在xib文件中设置了委托数据源插座连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM