替换UIViews [英] Replace UIViews
问题描述
我是iOS的新手.我有5个视图,一个是主视图,其他则像缩略图.如何替换视图.
I'm a newbie in iOS. I have 5 views, one mainview and the others are like thumbnails. How can I replace view.
例如,如果mainview(view1)具有图片1,view2具有图片2,view3具有图片3,依此类推.
For example, if mainview(view1) has picture 1, view2 has picture 2, view3 has picture 3 etc.
如何用图片2替换图片1,以使View2进入主视图?
How can I replace picture 1 with picture 2 so that View2 come in to the mainview?
有人可以帮我解决这个问题吗?
Could some one help me to solve this problem?
推荐答案
是的,可以像这样轻松完成View_1是第一个视图View_2是第二个视图containerView是View_1的主要超级视图View_1是当前可见的视图
Yes this could be done esily like this View_1 is the first view View_2 is the second view containerView is the main super view for View_1 View_1 is the currently visible view
[UIView beginAnimations:@"doTheFlipping" context:nil];
[UIView setAnimationDuration:.5];
[UIView setAnimationDelay:0];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(myTransitionDidStop:finished:context:)];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:containerView cache:YES];
[View_1 removeFromSuperview];
[containerView addSubview:View_2];
[UIView commitAnimations];
这将创建视图1到视图2的翻转视图
This will create a flip view for view 1 to view 2
这篇关于替换UIViews的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!