2012-03-09 39 views
2

我自去年半的-hour.I一個問題我使用UIButton,我想展示UIPopovercontroller上它。但是它崩潰上它touchUpinside action。我知道這可能如果我使用UIBarButton我們很容易做到,但我有一些UI specification這就是爲什麼我不能使用UIBarButtonUIToolbar我們如何在UIButton上添加UIPopOverController?

所以請如果有人有任何想法UIButtonUIPopovercontroller然後請幫助我。幫助將appriciated。

+1

你爲什麼不這裏發表您的代碼和崩潰報告。 – Dee 2012-03-09 20:16:41

回答

5
[popoverController presentPopoverFromRect:button.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 
0

您可以嘗試使用下面的代碼:

-(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** 

} 
相關問題