I have two UIViews in the first one is a variable number of UIButtons that emerge in two rows
Unfortunately, they only work when you call them in
ViewDidAppear: method or later. This means that when my thoughts are loaded and when my elements are positioned properly, there is a small amount in between.
How can I solve this problem beautifully?
Edit 1: Here's a simple way I'm using the View 2 adjustment
- Adjust (zero): (UIView *) See below: (int ) Below {CGRect frame = view.frame; Frame.origin.y = frame.origin.y + Down; View.frame = frames; } Edit 2: This is something like adding my button, changing the size of my first scene, and calculating how far the next one should go
- (Zero) addButtonsToView: (NSArray *) Button strings {// Float last tags Width = 0.0; Self.adjustdown = 0.0; (For NSString * str button button) {UIButton * button = [UIButtonTypeRoundedRect] with UIButton button; [Button Situation: Straight Forrest: (UIC Contolstate UIC IntrastalAnternal); CGSize size = [font size font: TAG_FONT]; If (previous togs width + size.width> 300) {previousTagsWidth = 0; Self.adjustown = + size.high + 10; } Button.frame = CGRectMake (PreviousLugsWithSwitch, Adjust, Size.width + 10, SizeHit +5); Previous latitude + = size Fourth + 20; [Self. View 1 Adsview: Button]; } CGRect frame = self.view1.frame; Frame.ize.height = frame.ize.height + self.adjustownown; Self.view1.frame = frames; }
why not viewWillLayoutSubviews or viewDidLayoutSubviews ?
(Do not forget to call super !)
No comments:
Post a Comment