gpt4 book ai didi

ios - 准备ForSegue( View Controller )

转载 作者:行者123 更新时间:2023-11-30 14:19:00 24 4
gpt4 key购买 nike

然后我尝试将数据从一个 View 发送到另一个 View

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

if segue.identifier == "varView" {
var viewController = segue.destinationViewController as ViewController

var indexPath = self.tableView.indexPathForSelectedRow()

viewController.varView = self.exams[indexPath.row]

}

}

我收到一个错误,witch said that ViewController is a undeclared?

最佳答案

您可以直接从 Storyboard调用viewController并传递数据,而不是prepareForSegue

在要传递数据的文件中声明变量,以及#import要在其中传递数据的头文件。

#import "file.h"

file *data = [[file alloc]init];
data.index = add_index;

然后按如下方式导航...

UINavigationController *navigationController = (UINavigationController *)self.navigationController;
UIViewController *createEvent = [self.storyboard instantiateViewControllerWithIdentifier:@"yourViewControllerID"];

[navigationController pushViewController:createEvent animated:YES];

关于ios - 准备ForSegue( View Controller ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30732550/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com