r/ObjectiveC • • Apr 01 '20

Problem: App resizes after starting it

I'm not that experienced and have run into a problem. I have to integrate an SDK from our business partner to enable subscription plans. I integrated it successfully but when I start the app on my device the screen first loads normal but then after the SDK loaded the screen gets resized and pushed into the lower-left corner... I also cannot click on anything I would normaly be able to.

Screenshot

I have absolutely no idea why this could be happening but it has to be because of the SDK. When integrating it I have to add some lines of code to the existing info.plist maybe that is the issue?

I hope someone can help me fix this issue!

Thank you very much!

6 Upvotes

11 comments sorted by

View all comments

Show parent comment

1

u/mariox19 Apr 01 '20 edited Apr 02 '20

Okay, I don't know what is going wrong, but this is what I think is going on and what I would do if I had a problem like this that I didn't understand.

First, I would make another project. The simplest thing possible—no fancy LaunchScreen or any other functionality. I would add only a button, and the code to integrate the ConnectFramework stuff.

My guess is that it's your code, not the third-party code. Maybe not, but you need to rule that out. My guess, based on your original post and a couple of minor things in the code you've shared, is that you may not have a firm grasp on how the Cocoa-Touch framework does things. I can't know this for sure, but I've seen this. (Where I work, our application is primarily legacy code built by someone who learned as he went along.) In short, I think you may be, as we say, fighting the framework (meaning: the Cocoa-Touch framework).

When you make your simple app, try to log everything you can. For instance, you should have something like this:

- (IBAction)showUpgradeOffer:(id)sender
{
    if (![PurchaseViewController didPurchase]) {
        UIViewController* pvc = 
            [PurchaseViewController createPurchaseViewControllerWithReusableHandler:^(BOOL didPurchase, NSString* productId) {
                if (didPurchase) {
                    NSLog(@"Purchased");
                }
                else {
                    NSLog(@"Did not purchase");
                }
        }];

        [self presentViewController:pvc animated:YES completion:^{
            // Log the pvc parent view, the rect of its frame, and anything else 
            // you can think of, since this block will execute after the view 
            // controller has loaded.
        }];
    }
    else {
        // The user already purchased, show premium content.
    }
}

For your view controllers you should make their views different background colors, so you'll know what is showing.

This should get you on the right track. Good luck!

1

u/noahcdesign Apr 01 '20

Wow thanks for this! I will try this asap!

1

u/[deleted] Apr 02 '20

Have you tried using the view debugger in Xcode? Show the problematic view and you can click around the frames.