【问题标题】:how to pass tableview from one view controller hide to another view controller unhide using button action如何使用按钮操作将 tableview 从一个视图控制器隐藏传递到另一个视图控制器取消隐藏
【发布时间】:2016-05-19 05:44:56
【问题描述】:

我是 IOS 新手,我创建了两个视图控制器。第一个视图控制器包含 tableview 作为 table1,第二个视图控制器包含按钮。我想将 table1 传递给第二个视图控制器并在按钮操作中取消隐藏 table1。

弹出第二个视图控制器

第二个视图控制器中按钮操作后的第一个视图控制器

【问题讨论】:

  • 您自己尝试过吗?你有什么代码可以提供吗?
  • 你在使用故事板还是
  • 是的,仅限故事板@JoyalClifford
  • 在第二个 VC 中无法通过输入表。您可以在第二个 VC 中传递表数据。
  • 是的,就我自己而言,您希望在第二个视图控制器@user3353890 中使用表格视图或按钮操作的哪个部分代码

标签: ios objective-c uitableview


【解决方案1】:

例如,假设我有两个视图控制器。第一个包含一个按钮,第二个需要了解第一个视图的信息。您可以将按钮连接到代码中使用 performSegueWithIdentifier: 方法的 IBAction,如下所示...

// When any of my buttons are pressed, push the next view
- (IBAction)buttonPressed:(id)sender
{
    [self performSegueWithIdentifier:@"MySegue" sender:sender];
}

// This will get called too before the view appears
- (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];
    }
}

有关更多信息,您可以查看:http://www.appcoda.com/storyboards-ios-tutorial-pass-data-between-view-controller-with-segue/

【讨论】:

    猜你喜欢
    • 2020-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-27
    • 1970-01-01
    相关资源
    最近更新 更多