Resizing on iOS 8

-1

[RESOLVED] Hi, I'm trying to get the code out of the code so I can do it. We negotiated more time with the customer and now everything is already right.

I have a UIView that is instantiated in runtime, everything was fine on the old iPhones, but now on 6 and 6+, these UIViews do not match the size of the parent UIView, which has leading and trailing constraints. In addition, these UIViews are in a cell of a table.

What I tried to do was call the [self.tableView reloadData] in the viewDidLayoutSubviews and in the viewDidAppear of the UIViewController, solved the problem, however the UIViewController appears with the view in the old size and then redraws to the new size little, then this is visible to the user) Is there any way I can do this resizing without being visible to the user?

int width = barView.frame.size.width;
UIImageView *backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, width, 10)];
            backgroundImageView.image = [backgroundImage resizableImageWithCapInsets:UIEdgeInsetsMake(2, 1, 1, 1)];

            [barView addSubview:backgroundImageView];

The problem is that when I do in viewDidLoad, the width is 280, when I do in viewDidAppear, the width is 374 ...

If there is a function in which I already have the size of the View but it has not yet been rendered, it would be ideal for me to update the table ...

    
asked by anonymous 24.03.2015 / 18:22

1 answer

0

So I understand, you're using layout constraints in your view tree, I just find it kind of weird for you to use frame for a specific view.

After you populate any view (this includes UITable View Cell ), which has size variation, you need to call two UIView methods to "tell" UIKit to update their views on the device's screen.

  • setNeedsLayout : to invalidate the current layout and update it in the next cycle, usually based on intrinsic size or frame.

  • layoutIfNeeded : to update the layout of your view based on current values.

  • I've had a similar problem and this has totally solved my problem, I hope it helps.

        
    09.04.2015 / 06:16