1
我有两个连接在一起的UIViewControllers
。根据点击哪个按钮更改内容?
第一个UIViewController
有4 UIButtons
,所有这些带我到第二个UIViewController
。
但是,内容应该根据我点击的按钮而改变。我怎样才能做到这一点?
我有两个连接在一起的UIViewControllers
。根据点击哪个按钮更改内容?
第一个UIViewController
有4 UIButtons
,所有这些带我到第二个UIViewController
。
但是,内容应该根据我点击的按钮而改变。我怎样才能做到这一点?
给每个按钮一个唯一的标签,并使用prepareForSegue:sender:
方法,您可以在其中检查点击按钮的标签,然后相应地更改您的内容。
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
UIButton *buttonSender = (UIButton *)sender;
NSLog(@"Tag of the button tag selected = %d", buttonSender.tag);
switch (buttonSender.tag) {
case 1:
// Content if button 1 was clicked.
break;
case 2:
// Content if button 2 was clicked.
break;
case 3:
// Content if button 3 was clicked.
break;
case 4:
// Content if button 4 was clicked.
break;
default:
break;
}
}
非常感谢! – user2164504 2013-03-13 09:04:38