문제

I have a UIScrollView with a small UITableView inside. In iOS-7 everything works perfectly, but in iOS-6 the table view does not show at all, completely invisible. Everything is instantiated, the delegate and data source methods are called, but the UITableView just not appears. A blank space and nothing else.

Anyone has any idea why this might be happening?

Update:

It's just the native UITableView with the native cells.

Here's some example code:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_gridTableData count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *gridCellId = @"gridCellID";

    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:gridCellId];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:gridCellId];
        [cell.textLabel setFont:[UIFont fontWithName:@"HelveticaNeue" size:12]];
        [[cell textLabel] setText:_gridTableNames[[indexPath row]]];
        [cell.detailTextLabel setFont:[UIFont fontWithName:@"HelveticaNeue" size:12]];
        [[cell detailTextLabel] setText:_gridTableData[[indexPath row]]];
    }

    return cell;
}
도움이 되었습니까?

해결책 2

After some recommended log statements, I've found where's the problem:

In iOS6 the height of the UITableView's frame turns to 0. During "viewDidLoad" the height is correct(94p), but after that the height is always 0.

But I really don't know why this is happening. In iOS7 the UITableView's height never changes.

So I can "fix" it by re-setting the UITableView's frame height in "viewDidLayoutSubviews", for example. But if anyone has a clean way of fixing this, or knows the origin of this behaviour, it will be appreciated.

다른 팁

Keep in mind that in iOS 7, by default, the background of cells is white. In 6 and earlier it's transparent. This means that if you have black text in a table that overlays a black background it will be invisible in 6 and earlier. (Seeing some screen shots would help.)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top