【问题标题】:How we can add UIPopOverController on UIButton?我们如何在 UIButton 上添加 UIPopOverController?
【发布时间】:2012-03-09 20:02:23
【问题描述】:
自从上半小时以来我遇到了一个问题。我正在使用UIButton,我想在上面显示UIPopovercontroller。但是它在touchUpinside action 上崩溃了。我知道如果我这样做我们可以轻松完成使用UIBarButton 但我有一些UI specification 这就是为什么我不能使用UIBarButton 和UIToolbar。
所以,如果有人对在UIButton 上显示UIPopovercontroller 有任何想法,请帮助我。我们将不胜感激。
【问题讨论】:
标签:
iphone
uibutton
uipopovercontroller
【解决方案1】:
[popoverController presentPopoverFromRect:button.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
【解决方案2】:
您可以尝试使用以下代码:
-(IBAction)Show_Menu_Controller:(id)sender
{
if (_colorPicker == nil) {
self.colorPicker = [[[ColorPickerController alloc] initWithStyle:UITableViewStylePlain] autorelease];
_colorPicker.delegate = self;
self.colorPickerPopover = [[[UIPopoverController alloc] initWithContentViewController:_colorPicker] autorelease];
}
[self.colorPickerPopover setPopoverContentSize:CGSizeMake(600.0f, 250.0f)];
[self.colorPickerPopover presentPopoverFromRect:CGRectMake(365,-118 , 300, 200) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES]; **//Set the Origin & Direction of PopOverController accordingly**
}