嗨我在一页中按下按钮连接到另一个视图时出错
你能帮我吗? 提前谢谢!这是我的代码
-(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来清理但仍然是错误
答案 0 :(得分:0)
您必须先初始化destinationviewcontroller,然后才能更改属性:
- (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
}}
我希望它能解决它。