簡體   English   中英

UITableView在IOS7中可見,但在IOS6中不可見

[英]UITableView visible in IOS7 but not visible in IOS6

我有一個帶有小UITableViewUIScrollView iOS-7一切工作正常,但在iOS-6 ,表格視圖完全不顯示,完全不可見。 一切都實例化,調用了委托和數據源方法,但沒有出現UITableView 一個空白,沒有別的。

任何人都不知道為什么會這樣嗎?

更新:

它只是帶有本地單元格的本地UITableView。

這是一些示例代碼:

- (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;
}

請記住,在iOS 7中,默認情況下,單元格的背景為白色。 在6及更早版本中它是透明的。 這意味着,如果表中的黑色文本與黑色背景重疊,則在6及更低版本中將不可見。 (查看一些屏幕快照會有所幫助。)

在一些推薦的日志語句之后,我發現了問題所在:

在iOS6中,UITableView框架的高度變為0。在“ viewDidLoad”期間,高度為正確(94p),但此后高度始終為0。

但是我真的不知道為什么會這樣。 在iOS7中,UITableView的高度永遠不會改變。

因此,例如,可以通過在“ viewDidLayoutSubviews”中重新設置UITableView的框架高度來“修復”它。 但是,如果任何人都有解決此問題的干凈方法,或者知道此行為的起源,我們將不勝感激。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM