LoginSignup
18
20

More than 5 years have passed since last update.

特定のsubviewを取得する

Posted at

公式リファレンスのviewのページには [view addSubView:]; でビューを追加できることまでは書いてあるが、追加したやつを一発で指定する方法が書いていないようだった。たぶん。

- (UIView *)viewWithTag:(NSInteger)tag を使う。

こんな感じ。

    UITableView *view = [[UITableView alloc] init];
    view.tag = 1;
    [superView addSubview: view];

    UIView *subView = [superView viewWithTag: 1];

tagはenumとかで管理するといいって書いてあった。

参考

18
20
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
20