parentPopoverController

parentPopoverController

本文介绍了使用-dismissPopoverAnimated取消UIPopoverController:不会调用委托?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的UIPopoverController与自己作为委托:
当我在Popover控制器外面接收电话,但是当我点击里面我也要关闭,所以我使用-dismissPopoverAnimated:但是委托不被调用在这种情况下。
这是正常吗?这是一个错误还是我做错了?

  newDocPopoverController = [[UIPopoverController alloc] initWithContentViewController:vc]; 
[newDocPopoverController setPopoverContentSize:CGSizeMake(240,44 * 4)];
[newDocPopoverController presentPopoverFromBarButtonItem:sender
allowedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
[newDocPopoverController setDelegate:self];

更新:



哦,不管问题的起因(无论是错误还是这是预期的行为)自己调用代理解决问题:)



当contentViewController的视图被触动时,我将调用如果([parentPopoverController.delegate popoverControllerShouldDismissPopover:parentPopoverController]){
[parentPopoverController dismissPopoverAnimated:父对象UIPopoverController的委托一个调用

 是]; 
[parentPopoverController.delegate popoverControllerDidDismissPopover:parentPopoverController];
} r];


解决方案

这是正常的预期行为。 b
$ b

引用 on popoverControllerDidDismissPopover:


I have my UIPopoverController with self as a delegate:I receive calls when I tap outside the popover controller, but when I tap inside I want to dismiss too, so I use -dismissPopoverAnimated: but delegate is not called in this case.Is this normal? Is this a bug or I am doing something wrong?

newDocPopoverController = [[UIPopoverController alloc] initWithContentViewController:vc];
[newDocPopoverController setPopoverContentSize:CGSizeMake(240, 44*4)];
[newDocPopoverController presentPopoverFromBarButtonItem:sender
                permittedArrowDirections:UIPopoverArrowDirectionAny
                                                        animated:YES];
[newDocPopoverController setDelegate:self];

UPDATE:

Oh, regardless the origin of the problem (Whether is a bug or this is the intended behavior) calling the delegate by myself solves the problem :)

When the contentViewController's view is touched I will call parent UIPopoverController's delegate a call.

if ([parentPopoverController.delegate popoverControllerShouldDismissPopover:parentPopoverController]){
    [parentPopoverController dismissPopoverAnimated:YES];
    [parentPopoverController.delegate popoverControllerDidDismissPopover:parentPopoverController];
}r];
解决方案

That's normal, expected behavior.

Quoting the Apple docs on popoverControllerDidDismissPopover::

这篇关于使用-dismissPopoverAnimated取消UIPopoverController:不会调用委托?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 07:52