3

iPadバージョンには次の問題があります。

UITabBar内にNavigationControllerがあります。電子メールフォームに似たルックアンドフィールのフォームを表示したい。

同じコードを使用して、モデルを中心に表示します。

// View to be displayed in the modal
AdhocViewController *controller = [[AdhocViewController alloc] initWithNibName:@"AdhocViewController" bundle:[NSBundle mainBundle]];
controller.caller = self;

// The form will need a navigation bar to cancel or save the form
UINavigationController *modalViewNavController = [[UINavigationController alloc] 
                                               initWithRootViewController:controller];

// Configurate the modal presentation and transition
modalViewNavController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
modalViewNavController.modalPresentationStyle = UIModalPresentationFormSheet;

// Show the new view
[self presentModalViewController:modalViewNavController animated:YES];

このコードはポートレートモードでは完全に機能しますが、ランドスケープではビューが部分的に画面の外に表示されます...そしてそれを解決する方法はまだ見つかりませんでした。

ここで見つけたソリューションのいくつかをテストします...

モデルビューをプリセットしてサイズを変更した後、次の行を追加してみてください。ただし、うまくいきません。

controller.view.superview.frame = CGRectMake(0, 0, 600, 700);
controller.view.superview.center = self.view.center;

なにか提案を?

ありがとう、

イワン

StackOverflowの参照:

4

3 に答える 3

5

iOS7の秘訣は、modalTransitionStyleをUIModalTransitionCrossDissolveに設定することです。

UIViewController *viewController = [[UIViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];

navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
navigationController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

[self presentViewController:navigationController animated:YES completion:nil];
navigationController.view.superview.frame = CGRectMake(0, 0, 800, 544);
navigationController.view.superview.center = self.view.center;

https://coderwall.com/p/vebqaq

于 2013-12-19T17:30:35.200 に答える
1

最後に、コードは次のとおりです。

// Remove the modalTransitionStyle to enable the default behaviour and change to PageSheet
modalViewNavController.modalPresentationStyle = UIModalPresentationPageSheet;
// Present the modal view and adapt the center depending of the orientation
[self presentModalViewController:modalViewNavController animated:YES];

UIDeviceOrientation _orientation = [controller interfaceOrientation];
if (UIDeviceOrientationIsPortrait(_orientation)){
    modalViewNavController.view.superview.center = CGPointMake(768/2, 1024/2 + 10);
} else {
    modalViewNavController.view.superview.center = CGPointMake(768/2 - 10, 1024/2);
}

+10と-10は、モーダルのNavigationControllerが画面上部に表示されていなかったためです。

それは...くだらない解決策です:SSですが機能します...誰かが提案を持っているなら知っておくといいでしょうが。

両方の方向に同じ中心を含める必要がある場合、スーパービューの方向が予期されたものではない可能性があるという継ぎ目。

このソリューションでは、ポートレート方向のモーダルビューを閉じると、少なくともiPadシミュレーターでは、自動的にポートレートモードに回転します...

最終的な解決策は、メインコントローラーであるUITabBarに対してpresentModalViewControllerを実行し、それに対しても実行されるdismissメソッドを更新することでした。

[tabbar presentModalViewController:modalViewNavController animated:YES];

UIDeviceOrientation _orientation = [controller interfaceOrientation];
if (UIDeviceOrientationIsPortrait(_orientation)){
    modalViewNavController.view.superview.center = CGPointMake(768/2, 1024/2 + 10);
} else {
    modalViewNavController.view.superview.center = CGPointMake(1024/2, 768/2 + 10);
}

ついに!!!!

ありがとうございました、

イヴァン

于 2011-09-22T23:27:54.783 に答える
0

iOS 7では、キーボードの出現後にモーダルビューコントローラーが左側に表示される問題を解決するために(UIModalPresentationFormSheetでEKEventEditViewControllerを提示するときに発生する問題)、次のようにします。

[self presentViewController:modalViewController animated:YES completion:^{
    modalViewController.view.superview.center = self.view.center;
}];
于 2014-09-17T13:50:33.607 に答える