gpt4 book ai didi

ios - 在 Storyboard 中的 didselectrowatindexpath 上推送 View

转载 作者:行者123 更新时间:2023-11-28 18:39:42 25 4
gpt4 key购买 nike

我在 Storyboard的其中一个 View Controller 中添加了一个 TableView 作为 subview 。它有 6 个部分,每个部分有一排。选择每一行时,应打开一个新的 View Controller 。有 6 个这样不同的 View Controller 。我不知道如何在 Storyboard 中实现这一目标。有什么方法可以通过 Storyboard绑定(bind)它,或者我必须手动执行此操作。任何帮助都会被接受。谢谢。

最佳答案

在 Storyboard中获取 View Controller 时使用performSegueWithIdentifier 方法。

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{


if (indexPath.section==0) {

[self performSegueWithIdentifier:@"first" sender:nil];

}
if (indexPath.section==1) {

[self performSegueWithIdentifier:@"second" sender:nil];

}
if (indexPath.section==2) {

[self performSegueWithIdentifier:@"third" sender:nil];

}
if (indexPath.section==3)
{

[self performSegueWithIdentifier:@"fourth" sender:nil];

}


}

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([[segue identifier] isEqualToString:@"first"])
{
friendsViewController=[segue destinationViewController];

}
if([[segue identifier] isEqualToString:@"second"])
{
secondViewController=[segue destinationViewController];

}
if([[segue identifier] isEqualToString:@"third"])
{
thirdViewController=[segue destinationViewController];

}
if([[segue identifier] isEqualToString:@"fourth"])
{
fourthViewController=[segue destinationViewController];



}
}

我想这对你有帮助。

关于ios - 在 Storyboard 中的 didselectrowatindexpath 上推送 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12743132/

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