ラベル UITableViewController の投稿を表示しています。 すべての投稿を表示
ラベル UITableViewController の投稿を表示しています。 すべての投稿を表示

2014年3月8日土曜日

UIRefreshControl を使って引っぱり更新をする。

iOS6で追加された引っぱり更新用のUIRefreshControlですが、先日私事でiOS5の呪縛から逃れたのでメモメモ。

※ちなみにiOSの6と7ではUIのビジュアルが違いますが、個人的にはiOS6の方が好きですが、手元に環境がないのでこの例はiOS7です。

UITableViewControllerにrefreshControlのプロパティがあるので、画面の初期化の時に設定。
UIControlEventValueChangedでイベントが取得出来るので、その設定も忘れずに。

// リフレッシュコントロール
[self setRefreshControl:[[UIRefreshControl alloc] init]];
[[self refreshControl] addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];

イベントの受け取りメソッドも定義。


- (void)refresh:(UIRefreshControl *)control
{
    // 回転開始
    [[self refreshControl] beginRefreshing];
    
    //
    // 処理
    //
    
    // 回転終了
    [[self refreshControl] endRefreshing];
}

「beginRefreshing」と「endRefreshing」でインジケーターの回転のタイミングを調節できるので、これでやりたい処理を挟みます。


こんな感じ。

2013年6月25日火曜日

UINavigationController内のIUTableViewControllerにタイトル・tintColorが設定できない。

UINavigationController作成して、内部にUITableViewControllerを設定した時に、どれに対して、titleとtintColorの設定をしていいか未だにわからなくなってしまいます。


// UINavigationControllerの初期化
// UITableViewController *_tableViewController; で定義してます。
[self set_tableViewController:[[UITableViewController alloc] initWithStyle:UITableViewStyleGrouped]];
[[[self _tableViewController] tableView] setDataSource:self];
[[[self _tableViewController] tableView] setDelegate:self];
[self addChildViewController:[self _tableViewController]];

// この場合のtitle設定はこう
[[self _tableViewController] setTitle:@"プロフィール"];

// tintColor設定はこう
[[[[self _tableViewController] navigationController] navigationBar] setTintColor:[UIColor orangeColor]];