Ios 情节提要中DidSelectRowAtIndex路径上的Pushview
我在故事板的一个ViewController中添加了一个tableview作为子视图。它有6个部分,每个部分有一行。选择每行时,应打开一个新的viewcontroller。有6个这样不同的ViewController用于此。我不知道如何在故事板中实现这一点。有没有办法通过故事板绑定,或者我必须手动绑定。任何帮助都会被接受。Ios 情节提要中DidSelectRowAtIndex路径上的Pushview,ios,uitableview,storyboard,pushviewcontroller,didselectrowatindexpath,Ios,Uitableview,Storyboard,Pushviewcontroller,Didselectrowatindexpath,我在故事板的一个ViewController中添加了一个tableview作为子视图。它有6个部分,每个部分有一行。选择每行时,应打开一个新的viewcontroller。有6个这样不同的ViewController用于此。我不知道如何在故事板中实现这一点。有没有办法通过故事板绑定,或者我必须手动绑定。任何帮助都会被接受。 谢谢。如果您的tableview带有静态单元格,并且所有单元格都放在故事板上,那么您可以使用ctrl按钮和鼠标左键轻松地从每个单元格拖动到所需的ViewController以
谢谢。如果您的tableview带有静态单元格,并且所有单元格都放在故事板上,那么您可以使用
ctrl
按钮和鼠标左键轻松地从每个单元格拖动到所需的ViewController以创建序列。如果您的tableview带有静态单元格,并且所有单元格都放在故事板上,然后,您可以使用ctrl
按钮和鼠标左键轻松地从每个单元格拖动到所需的ViewController以创建segue。当您在故事板中查看控制器时,使用performsguewithidentifier
方法
-(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];
}
}
我认为这将对您有所帮助。当您查看故事板中的控制器时,请使用
performsguewithidentifier
方法
-(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];
}
}
我认为这会对您有所帮助。是的,我使用过静态单元格,并且已经尝试过您所说的方式,但我面临的问题是,我使用的是viewcontroller,而不是tableviewcontroller。所以它显示“静态单元格仅在嵌入uitableviewcontroller中时有效”错误是的,我使用了静态单元格,并且已经尝试了您所说的方式,但我面临的问题是,我使用的是viewcontroller,而不是tableviewcontroller。因此,它显示“静态单元格仅在嵌入uitableviewcontroller中时有效”错误