以前にこの質問をしたことがありますが、回答がありませんでした。というわけで再質問です!
私はこのような4つのラジオボタンを持っています:
- (IBAction)optWine:(id)sender {
ChangeLabel.text = @"Hint: try a partial phrase such as 'cab' to find information on the single-vineyard cabernet's made at the Arcadian Winery";
}
- (IBAction)optWinery:(id)sender {
ChangeLabel.text = @"Hint: try a phrase such as 'arc' to find the beautiful Arcadian Winery in Lompac, California.";
}
- (IBAction)optGrape:(id)sender {
ChangeLabel.text = @"Hint: type partial phrases such as 'zin' for Zinfandel grape";
}
- (IBAction)optReview:(id)sender {
ChangeLabel.text = @"Hint: try a partial phrase such as 'arc' to check-out reviews on wines by the Arcadian Winery";
}
...そして、私はこのような他の4つのアクションボタンを持っています:
- (IBAction)btnSearchWineries:(id)sender {
WineriesViewController *review = [[WineriesViewController alloc] initWithNibName:nil bundle:nil];
review.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:review animated:YES completion:NULL];
}
- (IBAction)btnSearchGrapes:(id)sender {
GrapesViewController *review = [[GrapesViewController alloc] initWithNibName:nil bundle:nil];
review.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:review animated:YES completion:NULL];
}
- (IBAction)btnSearchWines:(id)sender {
WinesViewController *review = [[WinesViewController alloc] initWithNibName:nil bundle:nil];
review.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:review animated:YES completion:NULL];
}
- (IBAction)btnSearchReviews:(id)sender {
ReviewsViewController *review = [[ReviewsViewController alloc] initWithNibName:nil bundle:nil];
review.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:review animated:YES completion:NULL];
}
どのラジオ ボタンが押されているかに応じて、1 つのボタンを変更して、4 つの検索ボタンのいずれかをアクティブにしたいと考えています。このようなものですが、これは機能しません:
-(IBAction)btnSearch:(id)sender
{
switch (((UIButton *)sender).tag) {
case 1:
{
WinesViewController *review = [[WinesViewController alloc] initWithNibName:nil bundle:nil];
review.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:review animated:YES completion:NULL];
break;
}
case 2:
{
WineriesViewController *review = [[WineriesViewController alloc] initWithNibName:nil bundle:nil];
review.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:review animated:YES completion:NULL];
break;
}
break;
case 3:
{
GrapesViewController *review = [[GrapesViewController alloc] initWithNibName:nil bundle:nil];
review.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:review animated:YES completion:NULL];
break;
}
case 4:
{
ReviewsViewController *review = [[ReviewsViewController alloc] initWithNibName:nil bundle:nil];
review.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:review animated:YES completion:NULL];
break;
}
default:
break;
}
}
IB でタグを割り当てましたが、何も起こりません。また、個々のボタンにタグを割り当ててみましたが、何も起こりません。if ステートメントで文字列を使用しようとしましたが、何も起こりません。