找不到属性视图没有类型为secondViewController的对象

时间:2012-03-16 03:25:36

标签: xcode viewcontroller

secondViewController.h:

#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的对象 有什么问题?

1 个答案:

答案 0 :(得分:0)

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

此外,删除@synthesize secondViewController;