开发者

Back and forth, removeFromSuperView

开发者 https://www.devze.com 2023-03-09 04:17 出处:网络
Im a bit confused... I have a mainview, which by the click of a button shows a subview. What I want to do next is to

Im a bit confused...

I have a mainview, which by the click of a button shows a subview. What I want to do next is to be able to switch back and forth between the Main and the Sub, but when I do this, the return button FROM the subView makes the TO SubView button disabled...I cant seem to be able to access the Subview a second time. Nothing happens.

What I have is a UIButton, and an IBAction, which I have written the "[self.view removeFromSuperView];" in.

Please do not get me wrong here, I do get back to the mainView. The problem is that I cant go back to the subview afterwards.

I've read something in the documentation about retaining the subView...But I did not quite understand how to do it.

开发者_开发百科

Could anyone please shed some light over this?

Thanks!


this is just a guess, since you don't provide much code: - you might first need to retain the view. in case it's only retained by its current superview [self.view retain];

remember to free it manually when it's no longer needed. [self.view release];


Why dont you try out this?

to open ur subview:

Ursubview *Ursubview    =[[Ursubview alloc] initWithNibName:nil bundle:nil];
Ursubview.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentModalViewController:Ursubview animated:YES];

to go back:

[self dismissModalViewControllerAnimated:YES];


Why not just hide it instead of removing it?

0

精彩评论

暂无评论...
验证码 换一张
取 消