Bug fixes / tweaks to ReaderViewController and SearchResultView

jguengerich's Avatar

jguengerich

13 Sep, 2017 04:06 PM

ReaderViewController - use the requested contentSize to set the preferredContentSize for controllers presented on an iPad with a PopoverPresentationController, and change the order of statements to match the documentation for PPCs (present first, then configure PPC). Modified code (not sure why the forum is splitting this into 3 sections):

-(void)presentViewController:(UIViewController *)controller
               barButtonItem:(UIBarButtonItem *)barButtonItem
                 contentSize:(CGSize)contentSize
{
    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        if([UIPopoverPresentationController class]) {
            if(self.presentedViewController) {
                [self dismissViewControllerAnimated:YES completion:nil];
            }
            controller.modalPresentationStyle = UIModalPresentationPopover;
            controller.preferredContentSize = contentSize;  // added this line
            [self presentViewController:controller animated:YES completion:nil];  // moved this line before PPC configuration

        UIPopoverPresentationController * popoverPresentationController = controller.popoverPresentationController;

        popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionAny;
        popoverPresentationController.barButtonItem = barButtonItem;
        popoverPresentationController.delegate = self;
    }
    else
    {
        [self prepareReusablePopoverControllerWithController:controller];

        [self.reusablePopover setPopoverContentSize:contentSize animated:YES];
        [self.reusablePopover presentPopoverFromBarButtonItem:barButtonItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    }
}
else
{
    [self presentViewController:controller animated:YES completion:nil];
}



}

Also in ReaderViewController - make the page number label on the toolbar a little wider so large page numbers fit (for example, "Page 203 of 208"). I made it 170 instead of 150, but it could probably be even wider. Modified code (in prepareToolbar):

// Page number


UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 170, 23)]; // 170 instead of 150

SearchResultView - add a minimum size for the page number so it is visible. Modified code (in initWithFrame):

        [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[snippet]-[number(>=50)]-|" options:0 metrics:nil views:views]];
  1. 1 Posted by jguengerich on 13 Sep, 2017 04:35 PM

    jguengerich's Avatar

    In ReaderViewController, I guess the same PPC related changes should be made in:

    -(void)presentViewController:(UIViewController *)controller
                        fromRect:(CGRect)rect
                      sourceView:(UIView *)view
                     contentSize:(CGSize)contentSize
    
    also.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac