UIViewController remove subview

http://stackoverflow.com/questions/3028845/uiviewcontroller-remove-subview

 

找来的删除子视图的代码

 

I add a view as subview of my uiviewcontroller like this:

 

// into my ViewController:
UIImageView *imView =[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"img.jpg"]];
imView
.frame = CGRectMake(2, 46, 1020, 720);
[self.view addSubview:imView];

now, with another button I wish remove the imView from the subview chain.. how can I do to do this?? thanks

You can call this method, which belongs to UIView (and UIImageView inherits from UIView)

UIView - (void)removeFromSuperview


 

posted @ 2012-07-06 09:45  冰岛  阅读(364)  评论(0编辑  收藏  举报