0

同期画面の場合、ios5 で ModalViewController を作成しました。私はこのコードを使用しました:

    synchViewController = [[SynchViewController alloc] initWithNibName:@"SynchViewController" bundle:nil];
    synchViewController.modalPresentationStyle = UIModalPresentationFormSheet;

    [self presentModalViewController:synchViewController animated:YES];

    synchViewController.view.superview.frame = CGRectMake(0,0,SYNCHVIEW_WIDTH,SYNCHVIEW_HEIGHT);

    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    CGPoint center = CGPointMake(CGRectGetMidX(screenBounds), CGRectGetMidY(screenBounds));
    synchViewController.view.superview.center = CGPointMake(center.y, center.x);

コントローラーは、xib ファイルで設計されました。このコードは機能しました。

現在、ios6 では、presentModalViewController は減価償却されています。メソッドを変更しましたが、モーダル ビュー コントローラーが完全に移動し、サイズが間違っています。

設計した xib レイアウトのサイズで iMessage ログイン画面のようなものを作成するにはどうすればよいですか?

編集: このコードで動作します: synchViewController = [[SynchViewController alloc] initWithNibName:@"SynchViewController" bundle:nil];

    synchViewController.modalPresentationStyle = UIModalPresentationFormSheet;
    synchViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentViewController:synchViewController animated:YES completion:nil];
    synchViewController.view.superview.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
    synchViewController.view.superview.frame = CGRectMake(0,0,
                                                     SYNCHVIEW_WIDTH,// Width
                                                     SYNCHVIEW_HEIGHT// Height
                                                     );


    synchViewController.view.superview.bounds = CGRectMake(0, 0, SYNCHVIEW_WIDTH, SYNCHVIEW_HEIGHT);
    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    CGPoint center = CGPointMake(CGRectGetMidX(screenBounds), CGRectGetMidY(screenBounds));
    synchViewController.view.superview.center = CGPointMake(center.y, center.x);

ただし、アニメーションをYESに設定した場合のみ。アニメーションなしでロードしようとすると、再び完全に移動します。なぜですか?

4

1 に答える 1

1

次のコードで何を達成しようとしていますか?

synchViewController.view.superview.frame = CGRectMake(0,0,SYNCHVIEW_WIDTH,SYNCHVIEW_HEIGHT);
...
synchViewController.view.superview.center = CGPointMake(center.y, center.x);

モーダル(提示された)コントローラーのサイズと位置はによって定義されmodalPresentationStyle、変更しようとしても確実に機能することはありません。

提示されたコントローラーのサイズを変えたい場合は、(子ビューコントローラーとして)自分でコントローラーを作成し、それをビュー階層に挿入して、提示されたコントローラーでのユーザー操作をブロックする必要があります。

ただし、デフォルトサイズのネイティブモーダルコントローラーを使用することを強くお勧めします。

于 2012-11-30T12:13:51.757 に答える