gpt4 book ai didi

ios - 接收器没有带标识符的 segue ...以编程方式创建的 segue

转载 作者:行者123 更新时间:2023-11-28 21:42:35 26 4
gpt4 key购买 nike

以编程方式创建的 segue 在 performSegueWithIdentifier: 上使应用程序崩溃,不过我真的不想使用 Storyboard。

- (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;}

最佳答案

无法以编程方式创建转场。 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: 方法用于子类化目的。

就是说,如果您不使用 Storyboard,那么您实际上并不需要 segues。只需在需要时实例化并呈现目标 View Controller 即可。

关于ios - 接收器没有带标识符的 segue ...以编程方式创建的 segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31467028/

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