我以前问过这个问题,但没有收到回复。所以我又问了!
我有 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];
}
根据按下哪个单选按钮,我想更改一个按钮以执行 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 语句的字符串,没有任何反应。