Skip to content

In Landscape mode, when using Split View multitasking, ad container is wrong. (found fix!) #128

@CHPraxis

Description

@CHPraxis

So, what's happening is that your code checks if it is landscape or portrait, then if landscape, takes the larger of the height and width as the height. If the user is in landscape, but is using split view (therefore, height is larger than width), the iAd container gets the wrong result and the container starts floating in the middle.

I'm not sure why this logic exists; it seems like, if the user is in landscape, you can simply use the height as height, right? So, I tweaked your code to remove this logic. I commented out two lines and replace them with my lines beneath them. This is the part I modified.

Let me know if there's anything wrong with it? This is in LARSAdController.m .

- (CGRect)containerFrameForInterfaceOrientation:(UIInterfaceOrientation)orientation
                            withPinningLocation:(LARSAdControllerPinLocation)pinningLocation {
    //TODO: Modify height so that the container does not contain any whitespace above ad.
    //This will enable others to add a background to the container (a la weather channel app).
    CGFloat width;
    CGFloat yOrigin = 0.f;

    CGFloat parentWidth = CGRectGetWidth(self.parentView.frame);
    CGFloat parentHeight = CGRectGetHeight(self.parentView.frame);

    if (UIInterfaceOrientationIsLandscape(orientation)) {
        TOLLog(@"View is landscape");

        if (pinningLocation == LARSAdControllerPinLocationBottom) {
            //yOrigin = MIN(parentHeight, parentWidth);
            yOrigin = parentHeight;
        }
        //width = MAX(parentHeight, parentWidth);
        width = parentWidth;

        self.lastOrientationWasPortrait = NO;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions