Ios 直接从脚本xcode中的视图控制器警告启动的序列

Ios 直接从脚本xcode中的视图控制器警告启动的序列,ios,objective-c,storyboard,segue,uistoryboardsegue,Ios,Objective C,Storyboard,Segue,Uistoryboardsegue,嗨,我以编程方式创建了按钮,并将其连接到另一个视图,但我收到了segue警告 我应该使用prepareForSegue方法制作故事板,但我不知道怎么做,互联网上有一些示例,但我在使用该示例时出错,请您帮助我好吗 这是我的密码 创建按钮 UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom]; button.backgroundColor=[UIColor colorWithRed: 201.0/255.0 green

嗨,我以编程方式创建了按钮,并将其连接到另一个视图,但我收到了segue警告

我应该使用
prepareForSegue
方法制作故事板,但我不知道怎么做,互联网上有一些示例,但我在使用该示例时出错,请您帮助我好吗

这是我的密码

创建按钮

 UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom]; 
 button.backgroundColor=[UIColor colorWithRed: 201.0/255.0 green: 201.0/255.0 blue:201.0/255.0 alpha: 1.0];
 button.tag = currentTag;
 currentTag++;
 [button.layer setBorderColor: [[UIColor blackColor] CGColor]];
 [button.layer setBorderWidth: 1.0];
 [button setTitle:[NSString stringWithFormat:@"%d",currentTag] forState:UIControlStateNormal];
 button.frame = CGRectMake(80*x, 32*y, 80, 32); 
 [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
 [buttonView addSubview: button];
-(void)buttonPressed:(UIButton *)button
{
    NSLog(@"button %u -- frame: %@", button.tag, NSStringFromCGRect(button.frame));
    [self performSegueWithIdentifier:@"WeekView" sender:self];    
}
按钮操作

 UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom]; 
 button.backgroundColor=[UIColor colorWithRed: 201.0/255.0 green: 201.0/255.0 blue:201.0/255.0 alpha: 1.0];
 button.tag = currentTag;
 currentTag++;
 [button.layer setBorderColor: [[UIColor blackColor] CGColor]];
 [button.layer setBorderWidth: 1.0];
 [button setTitle:[NSString stringWithFormat:@"%d",currentTag] forState:UIControlStateNormal];
 button.frame = CGRectMake(80*x, 32*y, 80, 32); 
 [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
 [buttonView addSubview: button];
-(void)buttonPressed:(UIButton *)button
{
    NSLog(@"button %u -- frame: %@", button.tag, NSStringFromCGRect(button.frame));
    [self performSegueWithIdentifier:@"WeekView" sender:self];    
}
准备继续我的警告


直接从视图控制器启动的序列必须具有一个标识符,以便与-[UIViewController performSegueWithIdentifier:sender:]一起使用。

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

直接从视图控制器启动的序列必须具有标识符,以便与-
[UIViewController PerformsgueWithIdentifier:sender:://代码>

当您直接从情节提要中的视图控制器(又名,不是从按钮或任何动作控件)拖动序列,并且未键入标识符(名称)时,会出现此警告

你必须给它们一个标识符,否则就无法通过编程调用它们。。。这是你链接这样一个序列的唯一原因


在Xcode 8中,您应该能够双击警告,让情节提要显示有问题的片段,以便您可以为其添加名称。

在Xcode 5中,我不仅命名了片段,而且命名了它们指向的视图控制器,从而消除了此警告-每个视图控制器都需要一个情节提要ID。如果您只命名片段,则此警告无效(误导性)警告仍将出现。

我收到了相同的警告。您必须检查每个序列是否有XCool所说的标识符

Xcool-我在回顾一个较旧的项目时也遇到了这个问题。我必须单击每个故事板序列,检查它是否来自视图控制器。如果是,则我给它一个标识符


同时检查您的放松顺序!这为我解决了问题。

这解决了我的问题

转到情节提要>检查所有推送或弹出关系序列

选择每个序列关系>检查属性检查器属性>情节提要序列节

在该部分中,为所有序列提供标识符


你是通过编程还是在Interface Builder中创建Segue?接手一个有这样一个警告的项目太令人沮丧了-有没有办法告诉我这个Segue是在IB中的什么地方制作的?@powerj1984我在回顾一个老项目时也遇到了这个问题。我必须单击每个故事板Segue并检查它是否是原创的从视图控制器中删除。如果是,则我给它一个标识符。另一个解决方案是获得Xcode 5的帮助以识别源。专业提示:在情节提要中双击警告,它会将您跳转到违规者。此外,您还可以在日志文件中查看警告,并且应该有序列标识符。然后您只需打开情节提要作为该标识符的源代码和cmd+f。我有Xcode 8.0,双击打开一个新的故事板窗口