2012-03-16 29 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

相关问题