【发布时间】:2013-12-09 21:19:28
【问题描述】:
背景:我在应用中有表1和表2, 开始视图是表1,
实现什么:用户向右滑动,然后视图从左向右滑动并显示表格2
我的方法:
我尝试在表1和表2之间添加segue,使用push风格,问题是表2总是从右向左滑动,所以我放弃了这个方法
自定义动画:我添加了自定义转场,确实,当用户向右滑动时,我可以看到从左到右的过渡。问题是:表 2 只显示一次,然后变成黑屏。
我自定义的segue代码如下:
UIViewController* source = (UIViewController *)self.sourceViewController;
UIViewController* destination = (UIViewController *)self.destinationViewController;
CGRect sourceFrame = source.view.frame;
sourceFrame.origin.x = sourceFrame.size.width;
CGRect destFrame = destination.view.frame;
destFrame.origin.x = -destination.view.frame.size.width;
destination.view.frame = destFrame;
destFrame.origin.x = 0;
[source.view.superview addSubview:destination.view];
[UIView animateWithDuration:0.5
animations:^{
source.view.frame = sourceFrame;
destination.view.frame = destFrame;
}
completion:^(BOOL finished) {
UIWindow *window = source.view.window;
[window setRootViewController:destination];
}];
我怀疑这是由于完成代码:window setRootViewController:destination,因为表 1 和 2 使用的是 uitableviewcontroller 而不是 uiviewcontroller, 我试图将上面代码中的uiviewcontroller更改为uitableviewcontroller,但它仍然不起作用。
任何机构都知道如何解决这个问题? 源码可以在这里下载http://d.pr/f/tAkc
【问题讨论】:
-
我认为您的问题出在您的第二个 tableView 上。你有故事板吗?显示第二个 tableView (viewDidLoad) 的代码...
-
如果没有自定义segue,第二个表格视图显示正常,您可以从d.pr/f/tAkc找到源代码,其中包含所有代码,看看,谢谢
标签: ios objective-c uitableview ios7 uiviewanimation