UIBarButtonItems を使用して UIToolBar を作成しましたが、それらをタップすると、セレクターが呼び出されません。どんな助けでも大歓迎です。
アップデート
コメントの提案に基づいてコードを修正しましたが、残念ながらボタンはまだ機能しません。
-(void)buildBottomMenu
{
UIImage *newsImg = [UIImage imageNamed:@"243-globe"];
UIBarButtonItem *newsBtnItem = [[UIBarButtonItem alloc] initWithImage:newsImg style:UIBarButtonItemStylePlain target:self action:@selector(loadHome)];
UIImage *weatherImg = [UIImage imageNamed:@"25-weather"];
UIBarButtonItem *weatherBtnItem = [[UIBarButtonItem alloc] initWithImage:weatherImg style:UIBarButtonItemStylePlain target:self action:@selector(loadWeather)];
UIImage *sportsImg = [UIImage imageNamed:@"63-runner"];
UIBarButtonItem *sportsBtnItem = [[UIBarButtonItem alloc] initWithImage:sportsImg style:UIBarButtonItemStylePlain target:self action:@selector(loadSports)];
UIImage *entrnImg = [UIImage imageNamed:@"178-city"];
UIBarButtonItem *entrnBtnItem = [[UIBarButtonItem alloc] initWithImage:entrnImg style:UIBarButtonItemStylePlain target:self action:@selector(loadEntertainment)];
UIImage *videoImg = [UIImage imageNamed:@"69-display"];
UIBarButtonItem *videoBtnItem = [[UIBarButtonItem alloc] initWithImage:videoImg style:UIBarButtonItemStylePlain target:self action:@selector(loadVideoPage)];
UIImage *moreImg = [UIImage imageNamed:@"259-list"];
UIBarButtonItem *moreBtnItem = [[UIBarButtonItem alloc] initWithImage:moreImg style:UIBarButtonItemStylePlain target:self action:@selector(loadOptionsPage)];
UIBarButtonItem* flexibleSpace = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil action:nil];
[_bottomBar setItems:[NSArray arrayWithObjects:flexibleSpace,newsBtnItem,flexibleSpace,
weatherBtnItem,flexibleSpace,
sportsBtnItem,flexibleSpace,
entrnBtnItem,flexibleSpace,
videoBtnItem,flexibleSpace,
moreBtnItem,flexibleSpace,
nil]];
[self.view addSubview:_bottomBar];
}
サンプル セレクターを次に示します。
- (void)loadWeather
{
NSLog(@"Loading weather");
}