私は自分のプロジェクトにUIViewControllerのサブクラスを作成し、それを "RootViewController"によってモーダルプッシュされたビューにリンクしました。私は派生したクラスに全く変更を加えませんでしたが、 "SecondView"を押すと毎回黒に変わります。私は標準のUIViewControllerクラスにそのビューをリンクする場合、すべて正常に動作しますか?UIViewControllerのサブクラスで黒い画面が表示される
"SecondViewController"はUIViewControllerから派生しているので、問題はalloc/init関数と関係がありますが、どこから起動するのかはわかりません。
必要に応じて私の前にあるサンプルコードを提供できます。
これは派生サブクラスです:
#import "SecondViewController.h"
@interface SecondViewController()
@end
@implementation SecondViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self; }
- (void)loadView {}
- (void)viewDidLoad {
[super viewDidLoad]; }
- (void)viewDidUnload {
[super viewDidUnload];}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait); }
@end
ヘッダー:FYI、コメントは自動的にあまりにも生成され
#import <UIKit/UIKit.h>
@interface SecondViewController : UIViewController
@end
コードを入れてください、それは多くの助けになります –
完了。希望が役立ちます。 – user1242094
解決しました。 偶然、「関連」のトピックのトピックを見つけました。 理由を知りませんが、削除した後に - (void)loadView 機能がすべて正常に機能します。 サブクラスがXcodeによって自動的に生成されたので、まだ変わっています。 – user1242094