开发者

UITableView doesn't show elements

开发者 https://www.devze.com 2023-03-23 22:47 出处:网络
I have created Windows-based application, added UITabBarController. As elements of view in every tab i added navigation controller (from objects panel).

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


Check you have set up the delegate and dataSource outlet connections in the xib file.

0

精彩评论

暂无评论...
验证码 换一张
取 消