2012-03-16 13 views
2

secondViewController.h的對象:屬性視圖沒有發現任何類型secondViewController

#import <UIKit/UIKit.h> 

@interface secondViewController : UIViewController 

@end 

viewController.m:

#import "ViewController.h" 
#import "secondViewController.h" 

@interface ViewController() 

@end 

@implementation ViewController 
@synthesize secondViewController; 

- (IBAction)switchView:(id)sender{ 
    [self.view addSubview:secondViewController.view atIndex:0]; 
} 

屬性視圖沒有發現任何類型secondViewController的對象 有什麼麻煩嗎?

回答

0
-(IBAction)switchView:(id)sender{ 
secondViewController *second = [[secondViewController alloc] init]; 
[self.view addSubview:second.view atIndex:0]; 
} 

另外,刪除那個@synthesize secondViewController;

+0

我建立一個xib文件initWithNibName – leoliu 2012-03-18 12:58:42

相關問題