2012-05-30 21 views
0

我用presentModalViewController来呈现一个视图,然后我尝试使用removeFromSuperview删除UView,但它不再工作。使用presentModalViewController后UIView无法被删除

在使用命令presentModalViewController之前,从超级视图中删除Uiview没有任何问题。

改变了什么?

+0

有什么不好?视图仍然在超视图上还是有例外?你写的信息太少,-presentModalViewController不应该改变-removeFromSuperview的行为 – medvedNick

回答

4

首先,presentModalViewController已弃用,因此您不应该使用它。
根据UIViewController class reference,您应该使用presentViewController:animated:completion:来代替。

其次,如果你使用任何的present??ViewController方法,为了关闭它,你应该用合适的dismiss??ViewController这样的:

// Present the view controller 
[self presentViewController:viewController animated:YES completion:NULL]; 

// Later, to dismiss it: 
[self dismissViewControllerAnimated:YES completion:NULL];