我有一个类是一个UIViewController,所以在我的'MyViewController.h‘中我有:
@interface MyViewController : UIViewController然而,在'MyViewController.m‘中,如果我尝试覆盖loadView,-(void)loadView不会自动完成,而且由于我的视图没有显示,我相信这暗示了问题所在。
我确信我在做一些愚蠢的事情,但是我找不到任何关于这件事的东西。
这是我的loadView,如果有帮助的话:
-(void)loadView
{
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;
myInputView = [[MyInputView alloc] initWithFrame:CGRectMake(0, 0, screenWidth,screenHeight)];
myInputView.delegate = self;
myInputView.style = kGestureInputStyleFading;
myInputView.backgroundColor = [UIColor redColor];
}提前感谢!
发布于 2012-07-26 05:00:45
不要担心自动补全。只需定义您的
- (void) loadView方法并编译您的应用程序...如果它不工作,请添加一些代码,以便我们可以看到发生了什么。
在loadView中,您需要初始化视图控制器的view属性:
self.view = [[UIView alloc] init...];在您的案例中:
-(void)loadView
{
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;
myInputView = [[GestureInputView alloc] initWithFrame:CGRectMake(0, 0, screenWidth,screenHeight)];
myInputView.delegate = self;
myInputView.style = kGestureInputStyleFading;
myInputView.backgroundColor = [UIColor redColor];
self.view = myInputView;
}https://stackoverflow.com/questions/11658478
复制相似问题