[英]prepareForSegue (ViewController)
Then i try to sent data from one view to another 然后我尝试将数据从一个视图发送到另一个视图
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]
}
}
I get an error at witch says that ViewController is a undeclared? 我在女巫遇到错误时说ViewController是未声明的?
Rather than prepareForSegue
you can directly call viewController
from storyboard and pass the data 您可以直接从情节
viewController
调用viewController
并传递数据,而不是prepareForSegue
declare variable in the file you want to pass the data and #import
the header file in which you want to pass the data. 在要传递数据的文件中声明变量,并
#import
要在其中传递数据的头文件。
#import "file.h"
file *data = [[file alloc]init];
data.index = add_index;
then navigate as follow... 然后按照以下步骤导航...
UINavigationController *navigationController = (UINavigationController *)self.navigationController;
UIViewController *createEvent = [self.storyboard instantiateViewControllerWithIdentifier:@"yourViewControllerID"];
[navigationController pushViewController:createEvent animated:YES];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.