简体   繁体   中英

Multiple UIView in one UIViewController

I am developing a iPad App. There is one UIViewController which should show all relevant information. Inside this VC there are 2 UIViews: The first UIView on the first half of the Screen shows a Image and some text. The second View on the bottom half of the screen should display some stuff like a map or a image gallery depending on the button that was pressed in the center of the screen.

My first try was to load for example a GalleyViewController and then get his View and add this as a Subview to my BottonView like this:

-(void)galleryButtonPressedInCenter{
    GalleryViewController * gal = [[GalleryViewController alloc] initWithNibName:@"GalleryViewController" bundle:nil];
    [gal.view setFrame:CGRectMake(0,0,620,300)];
    [self.bottomView addSubview: gal.view];

But this will crash my app if I touch the View with my finger.

To show what I want to achieve: On the last Screenshot ( http://itunes.apple.com/de/app/ebookers-hotels-furs-ipad/id465464927?mt=8 ) you can see that in this App there is a ImageView and some other Stuff in the upper part and in the lower part there are multiple Views that are switched depending on the button that was pressed.

Make an empty fullscreen view. then add your subviews to that view.

  ViewController
      -UIView  (your new umbrella view)
          -UIView  (subView 1)
          -UIView (subview 2)

I don't think I've seen it documented in the helpfiles, but I'm finding that each "ViewController" can only have one UIView directly attached. I'm kinda new at this though, try it anyway :)

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