Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIDocumentInteractionController incompatibility #35

Closed
Thomas101 opened this issue Nov 12, 2014 · 3 comments
Closed

UIDocumentInteractionController incompatibility #35

Thomas101 opened this issue Nov 12, 2014 · 3 comments

Comments

@Thomas101
Copy link

Hi,

I've found an incompatibility with the UIDocumentInteractionController in iOS8. If you include the WYPopoverController in your project then run this code...

@property (nonatomic, strong) UIDocumentInteractionController* documentInteractionController;



NSString* path = [[NSBundle mainBundle] pathForResource:@"Untitled" ofType:@"pages"];
NSURL* url = [NSURL fileURLWithPath:path];
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:url];
self.documentInteractionController.delegate = self;
CGRect bottomCenter = CGRectMake((self.view.frame.size.width / 2) - 2, self.view.frame.size.height, 2, 2);
[self.documentInteractionController presentOpenInMenuFromRect:bottomCenter inView:self.view animated:YES];

The popover launches but now when you press the "More" button you end up in a recursive loop in the WYPopoverLibrary

- (void)sizzled_setPreferredContentSize:(CGSize)aSize
{
    [self sizzled_setPreferredContentSize:aSize];

    if ([self isKindOfClass:[UINavigationController class]] == NO && self.navigationController != nil)
    {
#ifdef WY_BASE_SDK_7_ENABLED
        if ([self respondsToSelector:@selector(setPreferredContentSize:)]) {
            [self.navigationController setPreferredContentSize:aSize];
        }
#endif
    }
}

As a pretty horrific fix I've done the following, but this is super brittle. It would be great to know what's actually up and get something in that's more re-usable

- (void)sizzled_setPreferredContentSize:(CGSize)aSize
{
    [self sizzled_setPreferredContentSize:aSize];

    if ([self isKindOfClass:[UINavigationController class]] == NO && self.navigationController != nil)
    {
#ifdef WY_BASE_SDK_7_ENABLED
        if ([NSStringFromClass([self class]) hasPrefix:@"_UIActivityUserDefaultsViewController"] == NO) {
            if ([self respondsToSelector:@selector(setPreferredContentSize:)]) {
                [self.navigationController setPreferredContentSize:aSize];
            }
        }
#endif
    }
}
@Bluezen
Copy link

Bluezen commented Nov 14, 2014

Hello,
This issue seems related to #22 and to what's happening when presenting a UIActivityViewController in a system popover.

Would you mind giving a try to the following fix? It should prevent the recursive loop even in your case:

- (void)sizzled_setPreferredContentSize:(CGSize)aSize
{
    [self sizzled_setPreferredContentSize:aSize];

    if ([self isKindOfClass:[UINavigationController class]] == NO && self.navigationController != nil)
    {
#ifdef WY_BASE_SDK_7_ENABLED
        if ([self.navigationController isEmbedInPopover]) {
            if ([self respondsToSelector:@selector(setPreferredContentSize:)]) {
                [self.navigationController setPreferredContentSize:aSize];
            }
        }
#endif
    }
}

@Thomas101
Copy link
Author

Yeah, I agree with you. That seems to have fixed the issue on my end.

Thanks very much!

@Bluezen
Copy link

Bluezen commented Nov 14, 2014

Thank you for having checked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants