Resizing in iOS 8

Asked

Viewed 99 times

-1

[RESOLVED] Guys, thank you so much for the answer, but I solved the problem by redoing what I already knew was wrong, this code was legacy, and was not good, but for lack of time I just needed to find a way to work. We negotiate more time with the client and now everything is already right.


Guys, I have an Uiview that is instantiated in Runtime, everything went well in the old iPhones, but now in the 6 and 6+, these Uiviews do not follow the size of the parent Uiview, which has constraints on the sides (Leading and trailing). In addition, these Uiviews are in a cell of a table.

What I tried to do, was to call [self.tableView reloadData] in viewDidLayoutSubviews and viewDidAppear from Uiviewcontroller, solved the problem, but Uiviewcontroller appears with the view in the old size and then redesigns itself to the new size (it takes a while, so it becomes 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 where I already have the View size but it has not yet been rendered, it would be ideal for me to update the table...

  • If possible show an excerpt of your code that is having trouble, it will be easier.

  • I put an excerpt there, thanks for the touch...

1 answer

0

From what I understand, you are using constraints layout in your Tree view, I just found it kind of weird that you use frame for a specific view.

After you popular any view (this includes UITableViewCell), size variation, you need to call two Uiview methods to "tell" Uikit to update your views on the device screen.

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

  2. layoutIfNeeded: to update your view layout based on current values.

I’ve had a similar problem and it totally solved my problem, I hope it helps.

  • because... it was a legacy code, I needed to solve it fast... but I renegotiated with the client and I remade it in the right way, thank you very much for the answer,

Browser other questions tagged

You are not signed in. Login or sign up in order to post.