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