开发者

Hide uiview, but not it's subview?

I have an app where i add ViewB as a subview to ViewA... But the background of ViewB is clearColor, which means that I can see ViewA through ViewB! If I set viewA to be hidden, ViewB goes away too!

I am making a "flip-transition" between the views, so I can't just remove ViewA and then add ViewB :-/

-Anybody got an idea about what I can do?


Here's my code:

[UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration开发者_Go百科:1.0];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
                           forView:mainTableView
                             cache:YES];
    [mainTableView addSubview:subTableView];
    [UIView commitAnimations];


"I am making a "flip-transition" between the views, so I can't just remove ViewA and then add ViewB :-/ " - actually yes, you can. As a first step, you should add ViewA to the parent view. Later on, when you want to do the flip, you remove ViewA, and add ViewB to the parent view, and you do the flip transition on the parent view.

Hope this helps.


I would recommend that you don't add the back view as a sub ViewB as a subview of ViewA. The best solution would be keeping them separate... The method previously mentioned (transitionFromView:toView:duration:options:completion:) is the correct method to use... just make sure you do not have one as a subview of the other... instead, if ViewA is going to be the "back view" then just do this...

[UIView transitionFromView:viewB toView:viewA options:UIViewAnimationOptionTransitionFlipFromRight completion:NULL];

UIViewAnimationOptionFlipFromRight is just one option... read docs for more options....


Check out the help for setAnimationTransition:forView:cache: - it sounds like you want to change the appearance of a view during a transition, flipping from one view to another, both views visible during the animation? In order to do this the docs suggest using a container view. The docs also suggest in iOS 4.0 and later that you use block-based animation.

Try using transitionFromView:toView:duration:options:completion:

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜