2012-01-17 99 views
0

我正在开发基于故事板的应用程序,使用XCode 4.2。我是新来的故事板,在此之前我使用这样创建一个类的新实例切换视图:无法使用故事板以编程方式切换视图?

if (x==1) 
{  
    theClass *theView ; 
    theView= [[theClass alloc] initWithNibName:nil bundle:nil]; 
    [theView setText:theText]; 
    [reader presentModalViewController:theClass animated:YES]; //where reader is an instance of the ZBar library 
} 

故事板,这里就是我试图代码:

if (x==1) 
{ 
    [self performSegueWithIdentifier: @"theNewView" sender: self]; 
} 

然后:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
    if ([[segue identifier] isEqualToString:@"theNewView"]) 
    { 
     [[segue destinationViewController] setText:theText]; 
     [reader presentModalViewController:[segue destinationViewController] animated:YES]; 
    } 
} 

我确信,这些链接制作精良,而且prepareforsegue方法被调用,但即使有这样的代码,新的观点并没有被加载?

回答

1

不要在prepareForSeque方法中调用presentModalViewController方法 - 此方法用于将信息传递到新的视图控制器。

请参阅post

有用的学习weblog post,用于开始使用故事板。

相关问题