2012-01-03 12 views
1

私のiPhone/iPadアプリには、本当に変わったUIグリッチがあります。私はその原因を見つけたいので、可能な限り小さなコードで新しいプロジェクトを作成しました。重要なコードは以下の通りです。UISplitViewControllerとモーダルUIViewControllerの問題

基本的には、2つのサブクラスを含むUISplitViewControllerがあります。ボタンをタップすると、最初のボタンがモーダルに表示され、UIModalPresentationFormSheetUIViewControllerサブクラスModalと表示されます。ボタンがタップされると、Textという別のUIViewControllerサブクラスが表示されますが、今度はUIModalPresentationFullScreenとなります。 Textには、UITextViewがあります。それをタップすると、すべてが大丈夫ですが、iPadのを回転させたとき、私はこれを取得:

enter image description here

白い部分がTextビューコントローラである、背景の赤い部分がViewControllerTwoです。

これはなぜ起こるのですか?それを解決するために私ができることは何ですか?ここで


プロジェクトです:MediaFire


ここでは、関連するソースコードです:

// AppDelegate.m 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 

    ViewControllerOne *one = [[ViewControllerOne alloc] init]; 
    ViewControllerTwo *two = [[ViewControllerTwo alloc] init]; 

    UISplitViewController *split = [[UISplitViewController alloc] init]; 
    split.viewControllers = [NSArray arrayWithObjects:one, two, nil]; 

    self.window.rootViewController = split; 

    self.window.backgroundColor = [UIColor whiteColor]; 
    [self.window makeKeyAndVisible]; 
    return YES; 
} 

// ViewControllerOne.m 

#import "Modal.h" 

@implementation ViewControllerOne 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    self.view.backgroundColor = [UIColor blueColor]; 

    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
    button.frame = CGRectMake(30, 30, 44, 44); 

    [button addTarget:self action:@selector(buttonTapped) forControlEvents:UIControlEventTouchUpInside]; 

    [self.view addSubview:button]; 
} 

- (void)buttonTapped 
{ 
    Modal *modalOne = [[Modal alloc] init]; 
    modalOne.modalPresentationStyle = UIModalPresentationFormSheet; 

    [self presentModalViewController:modalOne animated:YES]; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return YES; 
} 

// Modal.m 

#import "Text.h" 

@implementation Modal 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    UIButton *buttonOne = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
    buttonOne.frame = CGRectMake(30, 30, 44, 44); 
    buttonOne.tag = 1; 
    [buttonOne addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside]; 

    UIButton *buttonTwo = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
    buttonTwo.frame = CGRectMake(30, 100, 44, 44); 
    buttonTwo.tag = 2; 
    [buttonTwo addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside]; 

    [self.view addSubview:buttonOne]; 
    [self.view addSubview:buttonTwo]; 
} 

- (void)buttonTapped:(UIButton *)button 
{ 
    if (button.tag == 1) 
    { 
     Text *text = [[Text alloc] init]; 
     text.modalPresentationStyle = UIModalPresentationFullScreen; 
     [self presentModalViewController:text animated:YES]; 
    } 
    else 
    { 
     [self dismissModalViewControllerAnimated:YES]; 
    } 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return YES; 
} 

// Text.m 

@implementation Text 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    self.view.backgroundColor = [UIColor greenColor]; 

    UITextView *textView = [[UITextView alloc] initWithFrame:self.view.bounds]; 
    textView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 
    [self.view addSubview:textView]; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return YES; 
} 
+0

この現象を示すサンプルプロジェクトのダウンロードリンクを提供できますか? –

+0

@SebastianCelis今すぐアップロードしました。質問をご覧ください。 – fabian789

+0

アーカイブを構築できません。これは、プロジェクト外のファイルを参照します。 –

答えて

0

あなたが代わりにそれのサブビューのUISplitViewControllerからモーダルビューを提示する必要があるかもしれません。 ..

UISplitViewController *splitViewController = [(AppDelegate *)[[UIApplication sharedApplication] delegate] splitViewController]; 

[splitViewController presentModalViewController:modal animated:YES]; 
関連する問題