2014-10-02 66 views
0

这是我在xcode中添加新视图控制器的原始问题;xcode中的新视图控制器?

Adding a View Controller in Xcode?

这是我观察到的代码,即负荷出在Xcode一个新的项目为一个视图或者Controller.h /米文件

.H

@interface ViewController : UIViewController 

{ 


} 

@end 

.M

@interface ViewController() 

@end 

@implementation ViewController 

但是,当我添加一个新的类;我注意到没有'UIViewController'对象,而是有一个NSOBject。

.H

@interface Newclass : NSObject 
@end 

.M

@implementation Newclass 
@end 

我的问题;要成功以编程方式访问x代码故事板中的新视图控制器,是否必须将新的自定义.m/.h文件格式化为UIViewController或者是否重要。

回答

1

是的,要继承UIViewController需要的属性&必须'格式化'为(正确的术语是'继承自')一个UIViewController。所以:

@interface Newclass : UIViewController 
@end 

@implementation Newclass 
@end 
+0

谢谢你生病尝试 – godman 2014-10-02 19:36:39

+0

为什么不是UIViewController中使用,而不是NSObject的新类型 – godman 2014-10-03 06:24:35

相关问题