Ios 需要一些细节来在XCode中创建一个UI3按钮菜单,用于切换和更改主ViewController中的数据集

Ios 需要一些细节来在XCode中创建一个UI3按钮菜单,用于切换和更改主ViewController中的数据集,ios,xcode,uibutton,settings,viewcontroller,Ios,Xcode,Uibutton,Settings,Viewcontroller,我是Stackoverflow的新手,目前正在从头学习XCode,我正在制作一个带有选项的单页应用程序 有人知道如何高效地创建一个包含多个可选UI按钮的简单菜单,使主ViewController根据XCode中的选择显示不同的数据集吗 尝试了不同的方法(例如创建SecondViewController,但不知道如何将数据从它传递到主ViewController) 任何帮助都将不胜感激。请参阅: 以上答案参考的简单测试: 只需在prepareforsgue:method中获取对目标视图控制器的

我是Stackoverflow的新手,目前正在从头学习XCode,我正在制作一个带有选项的单页应用程序

有人知道如何高效地创建一个包含多个可选UI按钮的简单菜单,使主ViewController根据XCode中的选择显示不同的数据集吗

尝试了不同的方法(例如创建SecondViewController,但不知道如何将数据从它传递到主ViewController)

任何帮助都将不胜感激。

请参阅:

以上答案参考的简单测试:

只需在prepareforsgue:method中获取对目标视图控制器的引用,并将所需的任何对象传递到那里。这里有一个例子

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Make sure your segue name in storyboard is the same as this line
    if ([[segue identifier] isEqualToString:@"YOUR_SEGUE_NAME_HERE"])
    {
        // Get reference to the destination view controller
        YourViewController *vc = [segue destinationViewController];

        // Pass any objects to the view controller here, like...
        [vc setMyObjectHere:object];
    }
}
修订:您还可以使用performsguewithidentifier:sender:method根据选择或按钮按下激活到新视图的转换

例如,考虑到我有两个视图控制器。第一个包含三个按钮,第二个需要知道哪些按钮在转换之前已按下。您可以将按钮连接到代码中使用performsguewithidentifier:方法的iAction,如下所示

//当按下我的任何按钮时,按下下一个视图 -(iAction)按钮按下:(id)发件人 { [self-PerformsgueWithIdentifier:@“MySegue”发件人:发件人]; }

希望这有帮助,但请通过参考

请参考以下内容:

以上答案参考的简单测试:

只需在prepareforsgue:method中获取对目标视图控制器的引用,并将所需的任何对象传递到那里。这里有一个例子

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Make sure your segue name in storyboard is the same as this line
    if ([[segue identifier] isEqualToString:@"YOUR_SEGUE_NAME_HERE"])
    {
        // Get reference to the destination view controller
        YourViewController *vc = [segue destinationViewController];

        // Pass any objects to the view controller here, like...
        [vc setMyObjectHere:object];
    }
}
修订:您还可以使用performsguewithidentifier:sender:method根据选择或按钮按下激活到新视图的转换

例如,考虑到我有两个视图控制器。第一个包含三个按钮,第二个需要知道哪些按钮在转换之前已按下。您可以将按钮连接到代码中使用performsguewithidentifier:方法的iAction,如下所示

//当按下我的任何按钮时,按下下一个视图 -(iAction)按钮按下:(id)发件人 { [self-PerformsgueWithIdentifier:@“MySegue”发件人:发件人]; }

希望这有帮助,但请通过参考