问题
I know that Popover controllers are for use exclusively on iPad devices, but on below question there is a comment in which user has mentioned about category, code is as below, UIPopoverController for iphone not working?
// UIPopoverController+iPhone.h file
@interface UIPopoverController (iPhone)
+ (BOOL)_popoversDisabled;
@end
// UIPopoverController+iPhone.m file
@implementation UIPopoverController (iPhone)
+ (BOOL)_popoversDisabled {
return NO;
}
@end
Is this right way? Will Apple approve this?,
My iPad application is already done, now I am making it universal application, so instead of using any custom popover I want to add this category so that it will solve my issue and will reduce development efforts.
回答1:
This is very hacky way, and you'll be taking a big risk putting it on the AppStore. Sure someone may have put a version in the store where they overlooked this, but it can break any moment and Apple may decide to remove his app.
Have you tested popovers on iPhone? Will you test in iOS7.1? Will it work exactly the same on iOS7.2 or iOS 7.3?
A far better solution would be to take an open source implementation of popovers and use that for iPhone (or both).
回答2:
I have live app with with popover in iPhone. Just You have to create interface for popover
NSObject+UIPopover_Iphone.h
#import <Foundation/Foundation.h>
@interface UIPopoverController (overrides)
+(BOOL)_popoversDisabled;
@end
NSObject+UIPopover_Iphone.m
#import "NSObject+UIPopover_Iphone.h"
@implementation UIPopoverController (overrides)
+(BOOL)_popoversDisabled
{
return NO;
}
@end
and now just import NSObject+UIPopover_Iphone.h
in your Viewcontroller.h
Edit
For iOS 8 you can use WYPopoverController.
来源:https://stackoverflow.com/questions/20610067/uipopovercontroller-for-iphone-by-implementing-category