【发布时间】:2013-10-15 20:17:39
【问题描述】:
编辑:我找到了自己问题的答案。请看我帖子的底部。
我在尝试以编程方式将didSelectRowAtIndexPath 中的UIViewController 推送到UITableView 时遇到动画问题。当我在 iOS 6 中运行此代码时,它运行良好。在 iOS 7 中,动画被弄乱了(它向左移动了大约 20% 的屏幕然后消失了)。如果我在情节提要中执行此操作,则动画很好。我是否遗漏了一些东西,或者有没有办法在不使用情节提要的情况下解决这个问题?
// This is a cut down example.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIViewController *viewController = [[UIViewController alloc] init];
[self.navigationController pushViewController:viewController animated:YES];
}
这是 tableView 消失之前的样子。我明白它为什么这样做。这是因为被推送的新视图应该像使用情节提要一样动画滑入它。由于某种原因,它不能以编程方式工作。
编辑:这就是我错过的全部 出于某种原因,您必须设置背景颜色。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIViewController *viewController = [[UIViewController alloc] init];
[viewController.view setBackgroundColor:[UIColor orangeColor]];
[self.navigationController pushViewController:viewController animated:YES];
}
【问题讨论】:
-
您是否尝试过将其放在 UIView 动画块中,然后将动画设置为 NO 作为解决方法?
-
是您没有看到将
viewController推入堆栈的问题的一部分吗?还是只是旧的viewController仅向左移动了大约 20% 的问题? -
我的 ViewController 出现了。是动画不能正常工作。
-
我认为您需要在视图中包含内容或设置背景。但我不知道为什么...
标签: ios uitableview uinavigationcontroller ios7