简体   繁体   中英

How can I rezise a subview inside of an UIScrollView?

My app is built like this (i cannot post images)

UIViewController  
|  
|----UIView  
     |  
     |----UIScrollView   
          |  
          |----UIView (here are added my buttons, called contentView)

I would like to add buttons dinamically, depending on WebService response. I add these buttons programatically and it goes well, but the views lack space. To acomplish that goal, I have to resize the view in order to show correectly these new icons, but I cannot get the desired effect. What should I do to do this? Please, pardon my poor English xD.

== EDIT ==

Here is the code where I am adding some UISwitch to the contentView

  1. UISwitch *switchDebito=[[UISwitch alloc] initWithFrame:CGRectMake(260, 1080+(cantidadNotificacionesEnconrtadas * 35), 50, 35)];
  2. [switchDebito setOn:notification.NotificationDebit];
  3. [self.contentView addSubview:switchCredito];

In line 1 I create the switch, increasing its height eventually (not really important) Line 2 is pointless Line 3: here we add the switch to the contentView

Overwrite viewWillLayoutSubViews method in your view controller and set the content view frames inside it

- (void)viewWillLayoutSubViews {
     [super viewWillLayoutSubViews];
      //set your frames here
}

对于所有希望以相同问题查找araund的人,只需将滚动条的框架设置得更大,然后再设置内容视图框架,瞧!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM