Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在IOS中导航到情节提要中的目标视图控制器_Ios_Objective C_Uinavigationcontroller_Storyboard_Push - Fatal编程技术网

无法在IOS中导航到情节提要中的目标视图控制器

无法在IOS中导航到情节提要中的目标视图控制器,ios,objective-c,uinavigationcontroller,storyboard,push,Ios,Objective C,Uinavigationcontroller,Storyboard,Push,您好,我正在使用storyborad在IOS中创建UI。一切正常,但它不会导航到下一个视图控制器。我正在使用以下代码 [self performSegueWithIdentifier:@"identifier" sender:self]; and - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if([segue.identifier isEqualToString:@"identifier

您好,我正在使用storyborad在IOS中创建UI。一切正常,但它不会导航到下一个视图控制器。我正在使用以下代码

[self performSegueWithIdentifier:@"identifier" sender:self]; and 

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if([segue.identifier isEqualToString:@"identifier"]){

      ViewController *destVC =(ViewController *) [segue destinationViewController];

   }
我的Tableview代理

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
  static NSString *CellIdentifier = @"InfoCell";


        HMSForumInfoCell *cell = (InfoCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

        if (cell == nil)
        {
            NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"InfoCell" owner:self options:nil];
            cell = [nib objectAtIndex:0];
            cell.selectionStyle=UITableViewCellSelectionStyleNone;
            NSLog(@"Cell created");
        }


        NSDictionary *detailsDic = [_filteredListOfForums objectAtIndex:indexPath.row];


        [cell.headLinesLabel setText:[detailsDic objectForKey:kTopic]];

         // Adding underlined Colored text using NSMutableAttributedString

        NSMutableAttributedString *commentString = [[NSMutableAttributedString alloc] initWithString:[detailsDic objectForKey:kCreatedby]];


        UIColor* textColor = [UIColor colorWithRed:255.0f/255.0f green:198.0f/255.0f blue:0.0f/255.0f alpha:1.0f];
        [commentString setAttributes:@{NSForegroundColorAttributeName:textColor,NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleSingle]} range:NSMakeRange(0,[commentString length])];

        [cell.nameButton setAttributedTitle:commentString forState:UIControlStateNormal];


   //     [cell.nameButton addTarget:self action:@selector(replyButtonAction:) forControlEvents:UIControlEventTouchUpInside];


        [cell.nameButton addTarget:self action:@selector(namebuttonPressed:) forControlEvents:UIControlEventTouchUpInside];


        [cell.replyButton addTarget:self action:@selector(replyButtonPressed:) forControlEvents:UIControlEventTouchUpInside];



        return cell;
    }

    - (void)replyButtonPressed:(id)sender {


            [self performSegueWithIdentifier:@"id1" sender:self];

    }

    - (void)namebuttonPressed:(id)sender {


        [self performSegueWithIdentifier:@"id2" sender:self];


    }
请纠正我哪里做错了。
P.S:我已将视图控制器与故事板中的segueIdentifier正确连接,并将VC的类名更改为我的类。

您在PerformsgueWithIdentifier中的代码实际上没有任何作用。因此,要显示目标场景,必须在Interface Builder中进行连接,如下所示:

  • 将第一个场景嵌入导航控制器(菜单:编辑器/嵌入/导航控制器)
  • 创建第二个场景
  • 在第一个场景上创建触发第二个场景的控件
  • 将控件从第一个场景连接(Ctrl-Drag)到第二个场景
  • 在“鼠标按钮向上”的弹出菜单中,从序列中选择“按下”选项
那么它应该是这样的,并且应该工作:


希望这能有所帮助。

这段代码对您使用脚本ID更改视图控制器非常有用

比如说- 有两个视图控制器,分别名为FirstViewController和SecondViewController。 如果您想从FirstViewController移动到SecondViewController,有一个使用脚本ID的简单代码

第1步:-

输入两个ViewController的情节提要ID

第2步:-

在FirstViewController中编写代码-

let secondVC =  self.storyboard?.instantiateViewControllerWithIdentifier("SecondViewController") as! SecondViewController

self.navigationController?.pushViewController(secondVC, animated: true)

记录错误?例外?那么这里的问题是什么?请添加一些关于您的问题的更多信息,因为现在几乎无法回答。您使用的是模态序列吗?如果没有,你的故事板中是否有导航控制器检查你的segue标识符名称,它是否与segue名称匹配?可能您正在为segue使用情节提要viewcontroller标识符名称。我也检查了我的segue名称。控制将转到下一个视图控制器ViewDiLoad和tableview委派。问题是它没有显示下一个视图控制器@suhit