0

嗨,当我在一个页面中按下按钮以连接到另一个视图时出现错误

请你帮我提前谢谢!

这是我的代码

-(void)buttonPressed:(UIButton *)button
{
NSLog(@"button %u -- frame: %@", button.tag, NSStringFromCGRect(button.frame));
[self performSegueWithIdentifier:@"WeekView" sender:self];

}

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

    [segue.destinationViewController setTitle:@"WeekView"];
    }}

此行中的此错误

with debugging = Signal Sigabrat start from here

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

我还在 Segue 中识别 WeekView 并使用 shipt+command+K 清理但仍然错误

4

1 回答 1

0

您必须先初始化目标视图控制器,然后才能更改属性:

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

SecondViewController*second=segue.destinationViewController;   //You´re missing this line.

second.title=@"WeekView";    // now you can do stuff on your destinationViewController



    }}

我希望它能修复它。

于 2012-07-03T06:21:16.623 回答