Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 一段-几个按钮_Ios_Objective C_Uibutton_Segue - Fatal编程技术网

Ios 一段-几个按钮

Ios 一段-几个按钮,ios,objective-c,uibutton,segue,Ios,Objective C,Uibutton,Segue,好了,伙计们,事情是这样的 我正在尝试用一个序列连接两个视图,并在标签中从单击的按钮写入一个标记。我希望你明白我的意思 下面是一个例子: 标题视图出现,您必须选择难度1-3(按钮的标记值),单击后,您将移动到游戏视图,但您希望在游戏逻辑中使用标题视图按钮的标记值 以下是示例屏幕: 设置按钮以触发显示第二视图控制器的序列 在第一个视图控制器中,实现-(void)prepareforsgue:(UIStoryboardSegue*)segue sender:(id)sender,并使用sender检

好了,伙计们,事情是这样的

我正在尝试用一个序列连接两个视图,并在标签中从单击的按钮写入一个标记。我希望你明白我的意思

下面是一个例子: 标题视图出现,您必须选择难度1-3(按钮的标记值),单击后,您将移动到游戏视图,但您希望在游戏逻辑中使用标题视图按钮的标记值

以下是示例屏幕:
设置按钮以触发显示第二视图控制器的序列


在第一个视图控制器中,实现
-(void)prepareforsgue:(UIStoryboardSegue*)segue sender:(id)sender
,并使用sender检索标记。

设置按钮以触发显示第二个视图控制器的segue


在第一个视图控制器中,实现
-(void)prepareforsgue:(UIStoryboardSegue*)segue sender:(id)sender
,并使用sender检索标记。

这是我发现的,非常适合

// 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];
    }
}

这是整个主题的主题。

这是我发现的,非常适合

// 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];
    }
}

这是整个主题的主题。

太好了!根据你的建议,我能够解决这个问题,并找到了和我一样的例子!伟大的根据你的建议,我能够解决这个问题,并找到了和我一样的例子!