iOS5にはviewForHeaderInSectionはない

2013年7月29日月曜日

iOS5対応 メモ

t f B! P L
メモ

 UITableViewContollerで、viewForHeaderInSection はiOS6から。iOS5ではあってもエラーにならないが、グループ毎のヘッダーを表示したい場合(?)は、titleForHeaderInSection がいるようです。heightForHeaderInSection は iOS5でもiOS6でもどっちでも要る?

 iOSのバージョンの取得の一例

float systemVersion = [[[UIDevice currentDevice] systemVersion] floatValue];

 バージョンによる分岐は、cellForRowAtIndexPathでのセルの取得の仕方?が異なるようですのでそこでも使います。

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell*cell;
    
    if(systemVersion >= 6.0){
        cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    } else {
        cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if(!cell){
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        }
    }

 本当にこんなふうにするのかな?

このブログを検索

QooQ