嗨我已经以编程方式创建了按钮,并将其连接到另一个视图,但我收到了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];
Run Code Online (Sandbox Code Playgroud)
按钮动作
-(void)buttonPressed:(UIButton *)button
{
NSLog(@"button %u -- frame: %@", button.tag, NSStringFromCGRect(button.frame));
[self performSegueWithIdentifier:@"WeekView" sender:self];
}
Run Code Online (Sandbox Code Playgroud)
准备segue 我的警告
直接从视图控制器启动的Segues必须具有用于的标识符 - [UIViewController performSegueWithIdentifier:sender:]
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"WeekView"]) { …Run Code Online (Sandbox Code Playgroud)