UINavigationBarにインフォボタンを作る

UINavigationBarにインフォボタンを調べるのに割と時間がかかる。基礎がないとね。

参考つーかまんま:cocoa touch - how to create info button on uinavigationbar on iphone - Stack Overflow

  • UIButtonをbuttonWithTypeをUIButtonTypeInfoLightでつくる。これinfoButton
  • infoButtonに、addTargetする
  • UIBarButtonItemをinfoButtonをinitWithCustomViewでつくる。これをself.navigationItem のバーボタンにいれる にいれる。
    UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
    [infoButton addTarget:self 
      action:@selector(hoge) 
      forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem 
      = [[UIBarButtonItem alloc] initWithCustomView:infoButton];


げふ。