伙计们,这是交易...
我正在尝试将两个 View 与一个 segue 连接起来,并在标签中写入来自单击按钮的标签。我希望你明白我的意思...
例子如下: 出现标题 View ,您必须选择难度 1-3(按钮的标签值),点击后您将移至游戏 View ,但您希望在游戏逻辑中使用标题 View 按钮的标签值。
这是示例屏幕:
最佳答案
这是我发现的,非常适合!
// When any of my buttons are pressed, push the next view
- (IBAction)buttonPressed:(id)sender
{
[self performSegueWithIdentifier:@"Segue" sender:sender];
}
// This will get called before the view appears
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"Segue"]) {
// Get destination view
SecondView *vc = [segue destinationViewController];
// Get button tag number (or do whatever you need to do here, based on your object
NSInteger tagIndex = [(UIButton *)sender tag];
// Pass the information to your destination view
[vc setSelectedButton:tagIndex];
}
}
这里是 link整个主题。
关于ios - 一个 segue - 几个按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16043648/