[英]RootViewController cannot use 'super' because it is a root class
[英]Xcode 4.3.2 gives error “cannot use super because it is a root class”
最近,當我更新到xcode 4.3.2時,遇到了許多新問題。 在我的應用程序視圖控制器m文件中,我不斷收到錯誤“無法使用super,因為它是根子句”。
我已經在互聯網上看了幾個小時,所以對您的幫助將不勝感激。
謝謝
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
@end
如果您的類繼承自另一個自定義類,並且在頭文件中使用了祖先類的前向聲明( @class MyAncestorClass
),但又忘記在實現文件中#import
祖先類,則也可能會出現此錯誤。
聲明類時,您可能在@interface
行中忘記了超類。 例如,你做了
@interface MyClass
{
// ... ivars ...
}
// ... methods ...
@end
您希望第一行是:
@interface MyClass : NSObject
或您打算使用的任何超類。
如果您在phonegap中遇到此問題,使用此解決方案將有所幫助
#import <Cordova/CDVViewController.h>
#import <Cordova/CDVCommandDelegateImpl.h>
#import <Cordova/CDVCommandQueue.h>
@interface MainViewController : CDVViewController
@end
@interface MainCommandDelegate : CDVCommandDelegateImpl
@end
@interface MainCommandQueue : CDVCommandQueue
@end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.