简体   繁体   中英

How to add (insert) view to the superview

I want to know how to add imageview to the super view. this is how program works. 1.superview have childview 2.choose liitle picture from the childview 3.remove child view and send selected picture to the superview I just dont know where to begin, please help me guys.

#import "SecondLevelView.h"
#import "StickerViewController.h"

@implementation SecondLevelView

-(IBAction)switchStickerView:(id)sender{

    StickerViewController *stickerController = [[StickerViewController alloc] initWithNibName:@"StickerViewController" bundle:nil];

    self.stickerViewController = stickerController;
    [self.view insertSubview:stickerViewController.view atIndex:1];
    [stickerController release];
    [super viewDidLoad];

}

so this is rootview. it has toolbar to call stickerViewController. I draw picture for StickerViewcontroller through stickerView.h file. so, what Im stuck on is, when I choose picture from code in stickerview.m, I want ro send picture to secondlevelview.

[viewToMove retain];  //since detaching from super will decrement retain count. 
UIView *myRootView = [viewToMove superview];
[viewToMove removeFromSuperview];
[myRootView addSubview: viewToMove];
[viewToMove release];

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