ios - 一个 segue - 几个按钮

标签 ios objective-c uibutton segue

伙计们,这是交易...

我正在尝试将两个 View 与一个 segue 连接起来,并在标签中写入来自单击按钮的标签。我希望你明白我的意思...

例子如下: 出现标题 View ,您必须选择难度 1-3(按钮的标签值),点击后您将移至游戏 View ,但您希望在游戏逻辑中使用标题 View 按钮的标签值。

这是示例屏幕: enter image description here

最佳答案

这是我发现的,非常适合!

// 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/

相关文章:

iphone - iOS iPhone 中的可拖动按钮,使其在触摸结束后重新定位到其原始位置。

swift - 当应用程序进入后台时按钮跳转位置

ios - UIButton 无法在 iPhone 屏幕底部正确注册触摸

ios - 我无法在 iTunes 中显示我的应用程序图标

iphone - 从 UITextField 添加一个对象到 NSMutableArray

ios - 快速连续多次创建 UIAlertView

iOS - UIButton 作为 UIAlertController 上的 subview 未触发事件

ios - 是否允许在 iOS 应用程序中包含 Youtube 视频

ios - UITableviewCell 内的按钮 - 将数据传递给选择器

iphone - 确定 iOS 设备上可能的最大同时触摸数?