然后我尝试将数据从一个视图发送到另一个视图
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]
}
}
我在女巫那里得到一个错误,说ViewController是未声明的?
答案 0 :(得分:0)
而不是prepareForSegue
您可以直接从故事板调用viewController
并传递数据
在要传递数据的文件中声明变量,在#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];