嗨,我以编程方式创建了按钮并将其连接到另一个视图,但我收到了 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];
}
准备继续 我的警告
直接从视图控制器启动的 Segue 必须具有与 -[UIViewController performSegueWithIdentifier:sender:] 一起使用的标识符
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"WeekView"]) {
[segue.destinationViewController setTitle:@"WeekView"];
}
}