2010-06-12 108 views
3

我添加了一个视图,这样我的UIViewController子视图:UIViewController中删除子视图

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

现在,另一个按钮,我想从子视图链中删除imView .. 我该怎么做才能做到这一点? ? 感谢

回答

5

您可以调用该方法,它属于的UIView(和从UIImageView的UIView的继承)

UIView - (void)removeFromSuperview

+0

的感谢!我试过,但uimage视图仍然在视图控制器... 我看着你的链接,并写道'显示时从不调用此方法。'... 但我需要删除时显示... – ghiboz 2010-06-12 14:00:44

+1

是你确定是“什么时候显示”而不是“什么时候显示”?你可以看看这个问题,它可以回答你的问题: http://stackoverflow.com/questions/1144496/how-to-correctly-removefromsuperview – vodkhang 2010-06-12 14:05:08

+0

谢谢!我会尽力! – ghiboz 2010-06-12 14:38:24