Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
235 views
in Technique[技术] by (71.8m points)

objective c - UIPopoverController for iphone not working?

I need to use a UIPopOverController for my iPhone app ,i searched stackoverflow someone said UIPopoverController does not run on iphone iphone device WHY?.when i run on iphone device i got this error reason: '-[UIPopoverController initWithContentViewController:] called when not running under UIUserInterfaceIdiomPad.'

 -(void)btnSetRemainderTapped:(UIButton *)button
{
   setReminderView =[[SetRemainderView alloc]initWithNibName:@"SetRemainderView" bundle:[NSBundle mainBundle]];
setReminderView.contentSizeForViewInPopover = CGSizeMake(setReminderView.view.frame.size.width, setReminderView.view.frame.size.height);
setReminderView.delegate = self;
popOverController = [[UIPopoverController alloc]
                      initWithContentViewController:setReminderView] ;
 CGRect rect = CGRectMake(self.view.frame.size.width/2, self.view.frame.size.height/2, 1, 1);
[popOverController presentPopoverFromRect:rect
                                        inView:self.view
                      permittedArrowDirections:UIPopoverArrowDirectionAny
                                      animated:YES];
}

can any one help me?

question from:https://stackoverflow.com/questions/14787765/uipopovercontroller-for-iphone-not-working

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You CAN use popoverController in iPhone apps.

1. Create a category

// UIPopoverController+iPhone.h file
@interface UIPopoverController (iPhone)
+ (BOOL)_popoversDisabled;
@end

// UIPopoverController+iPhone.m file
@implementation UIPopoverController (iPhone)
+ (BOOL)_popoversDisabled {
    return NO; 
} 
@end

2. Import it to your class and use popover in iPhone as usual.

But remember that this is private method and Apple can reject your app. But I know people who use this normally and Apple published their apps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...