2017-09-27 3 views
7

新しいiOS 11のアップデート以降、シミュレータとデバイスに空白のテーブルビュー行を表示するアプリがあります。行区切り記号は、そこに存在するはずの行のいずれにも表示されません。シミュレータを古いiOSバージョンに変更すると、行が正常に表示されます。コードやストーリーボードに変更はありません。Xcode 9 - iOS 11 UITableViewの行が空です

行にはまだデータがあります。つまり、空白の行の1つをタップすると、コードが実行され、予想していた情報が含まれます。

テーブルビューがビュー上に配置されていて、内蔵のテキストラベルを使用していない他のシーンは正常に動作しているようです。組み込みのテキストラベルを使用するこのテーブルビュークラス。ここで

は、テーブルビュークラスの私のコードです...

@interface BunkPickTableViewController() 

@end 

@implementation BunkPickTableViewController 

@synthesize appDelegate, delegate, bunkPassedValue; 

- (void)viewDidLoad { 

    [super viewDidLoad]; 

    UIView *backgroundView = [[UIView alloc] initWithFrame:self.view.bounds]; 

    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; 

    CAGradientLayer *bgLayer = [BackgroundLayer tanGradient]; 
    bgLayer.frame = self.view.bounds; 
    [self.view.layer insertSublayer:bgLayer atIndex:0]; 

    self.tableView.backgroundView = backgroundView; 

    [self.navigationController.navigationBar setTintColor:[UIColor blackColor]]; 

    self.title = @"Bunk Codes"; 

} 

- (void)viewWillAppear:(BOOL)animated { 

    [super viewWillAppear:animated]; 

    [[self navigationController] setNavigationBarHidden:NO animated:NO]; 

    [self.tableView reloadData]; 

} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
} 

#pragma mark - Table view data source 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return [appDelegate.bunkArray 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]; 

     cell.textLabel.textAlignment = NSTextAlignmentCenter; 

     cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 

     cell.backgroundColor = [UIColor clearColor]; 

    } 

    Bunk *bunkObj = [appDelegate.bunkArray objectAtIndex:indexPath.row]; 

    cell.textLabel.text = bunkObj.bunkId; 

    return cell; 

} 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 

    [tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark; 

    [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; 

    Bunk *bunkObj = [appDelegate.bunkArray objectAtIndex:indexPath.row]; 

    [delegate dismissBunkPop:bunkObj.bunkId]; 

    [self.navigationController popViewControllerAnimated:YES]; 

} 

@end 

TableView Settings Image

+0

コードをステップ実行すると、 'cell.textLabel.text'は正しい値を取得しますか? – Koen

+0

それは、私はブレークポイントし、正しい数の行が正しい情報を取得していることを確認しました。すべてがよさそうだ。 – Kryckter

+1

私はios10で完全に動作するプロジェクトで同様の問題を抱えています(すべてのセルが空白になり、グループタイトルのみが正常です)。私はそれを見ている。 – ZDidier

答えて

3

IOS 11が..空白のセルを示すが、IOS 10で大丈夫だったと私は、この問題を持っていました。私の問題は、何らかの理由でセルテキストが表示されなくなったグラデーションを使用していることでした。グラデーションを削除すると、空白のセルが解決されました。

+0

これは本当に質問に答えません。別の質問がある場合は、[質問する](https://stackoverflow.com/questions/ask)をクリックして質問することができます。十分な[評判](https://stackoverflow.com/help/)があれば、この問題にもっと注意を払うために[奨励金を追加](https://stackoverflow.com/help/privileges/set-bounties)することもできます何が評判か)。 - [レビューより](/レビュー/低品質の投稿/ 17595014) –

3

tableViewbgLayerになっている可能性があります。

問題はself.view.layer insertSublayer:bgLayer atIndex:0にあるようです。インデックス0にinsertSubviewを使用していましたが、同じ問題がありました。これはおそらくiOS 11のバグです。もしあなたのtableViewがストーリーボードに定義されていれば、常に元に戻ってきます。

bgLayertableView.backgroundViewの中に入れることをお勧めします。

注: またviewDidAppearbgLayersendSubviewToBackを呼び出すことによってそれを解決することができますが、unfortunetaly、テーブルビューのセルは、すべてのテーブルビューのreloaddataにバックアップする動いているので、それは良い解決策ではありません。

+0

よくできました。ありがとう:私は自分のbackgroundViewを削除しました [self.tableView insertSubview:backgroundView atIndex:0];期待通りに働く – ZDidier

0
CAGradientLayer *gradient = [CAGradientLayer layer]; 
gradient.frame = self.tableView.bounds; 
gradient.colors = @[(id)[UIColor blackColor].CGColor, (id)[UIColor 
        grayColor].CGColor, (id)[UIColor 
        lightGrayColor].CGColor]; 

UIView *bgView = [[UIView alloc] 
          initWithFrame:self.tableView.bounds]; 
[self setBackgroundView:bgView]; 
[bgView.layer insertSublayer:gradient atIndex:0]; 

[self.tableView setBackgroundView:bgView]; 

tableviewの背景ビューのグラデーションレイヤーを設定すると、この問題が解決しました。私たちはiOS 10まで直接tableViewにサブレイヤを挿入することができますが、iOS 11ではUITableVIewのバックグラウンドビューにのみレイヤを挿入する必要があります。

0

上記のtableviewサブビュー操作と並行して、プロジェクトがXcode 9より前に存在し、ストーリーボードでセーフエリアレイアウトガイドを使用するチェックボックスをオンにした場合にもこの問題が発生する可能性があります。それをオフにして、それが機能するかどうかを確認してみてください。

関連する問題