1

ポップオーバーを使用してビューを表示しようとしています。UIPopoverController は IPhone では機能しないため、WEPopoverController を使用します。

私のコード:

UIViewController *controller = [[UIStoryboard storyboardWithName:@"Main" bundle:nil]instantiateViewControllerWithIdentifier:@"GetDateController"];
controller.modalPresentationStyle = UIModalPresentationPopover;
WEPopoverController *pop = [[WEPopoverController alloc] initWithContentViewController:controller];
pop.delegate = self;
CGRect screen = [[UIScreen mainScreen]bounds];
CGRect r = CGRectMake(8, 8, screen.size.width-8, 57);
pop.popoverContentSize = r.size;
[pop presentPopoverFromRect:CGRectMake(200, 100, 0, 0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

プログラムを起動すると、ポップ オーバー ウィンドウが表示されますが、すぐに消えます。IPhone プログラムのクラッシュで UIPopoverController を使用すると、iPad ではすべてが正しく動作します。

WEPopoverController を機能させるにはどうすればよいですか?

アレクサンダー。

4

1 に答える 1

1

これは、View Controller が作成したポップオーバーを所有しておらず、強い参照がなく、ARC がポップオーバーの参照カウントが 0 であることを検出し、すぐに解放したためです。必要なことは、作成後にビュー コントローラーのプロパティとしてポップオーバーを作成することだけです。

于 2016-04-22T08:21:50.063 に答える