接收器没有带标识符的 segue ...以编程方式创建的 segue
Receiver has no segue with identifier ... programmatically created segue
以编程方式创建的 segue 在 performSegueWithIdentifier: 上使应用程序崩溃,不过我真的不想使用故事板。
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
ViewController *viewController = [[ViewController alloc] init];
self.segue = [[UIStoryboardSegue alloc] initWithIdentifier:@"showInfo" source:self destination:viewController];
//change the background color to white
self.view.backgroundColor = [UIColor whiteColor];
//create the table view
UITableView *tableView = [[UITableView alloc] init];
//initialize the data source and the delegate to self - as the methods are going to be specified in this script
tableView.dataSource = self;
tableView.delegate = self;
//register the class for the tableView
[tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
//now assign the table view to our our viewController's property
self.view = tableView;}
无法以编程方式创建 Segue。 Apple 的文档说:
You do not create segue objects directly. Instead, the storyboard runtime creates them when it must perform a segue between two view controllers.
initWithIdentifier:source:destination: 方法用于子类化目的。
就是说,如果您不使用故事板,那么您实际上并不需要 segues。只需在需要时实例化并显示目标视图控制器即可。
以编程方式创建的 segue 在 performSegueWithIdentifier: 上使应用程序崩溃,不过我真的不想使用故事板。
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
ViewController *viewController = [[ViewController alloc] init];
self.segue = [[UIStoryboardSegue alloc] initWithIdentifier:@"showInfo" source:self destination:viewController];
//change the background color to white
self.view.backgroundColor = [UIColor whiteColor];
//create the table view
UITableView *tableView = [[UITableView alloc] init];
//initialize the data source and the delegate to self - as the methods are going to be specified in this script
tableView.dataSource = self;
tableView.delegate = self;
//register the class for the tableView
[tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
//now assign the table view to our our viewController's property
self.view = tableView;}
无法以编程方式创建 Segue。 Apple 的文档说:
You do not create segue objects directly. Instead, the storyboard runtime creates them when it must perform a segue between two view controllers.
initWithIdentifier:source:destination: 方法用于子类化目的。
就是说,如果您不使用故事板,那么您实际上并不需要 segues。只需在需要时实例化并显示目标视图控制器即可。