[英]prepareForSegue (ViewController)
然后我嘗試將數據從一個視圖發送到另一個視圖
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是未聲明的?
您可以直接從情節viewController
調用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];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.