我使用UITableView来呈现各种viewControllers.根据单击的索引,它将显示一个不同的视图控制器,然后可以将其解除.出于某种原因,我的一个ViewControllers需要两次点击才能显示.因此,似乎每个其他点击都有效.其他视图演示工作正常,所以表可能没问题.
我在ViewController中看到的即将显示的是,在第一次单击时,它通过didSelectRowAtIndexPath进行,然后在目标视图中触发:ViewWillLoad,ViewLoaded,ViewWillAppear ....但不是ViewDidAppear.在第二次单击时,只有ViewDidAppear会在显示时触发.在第二次单击时,它甚至没有通过didSelectRowAtIndexPath.此外,我可以第二次点击屏幕上的任意位置,它将显示.
它将继续来回执行此操作,似乎只显示每隔一次点击的目标视图.有没有想过为什么会这样?
/* RightPanelViewController */
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
switch(indexPath.row){
case 0:
// this view takes two clicks to display
[self presentViewController:self.delegateRef.savedRidesViewController animated:YES completion:nil];
break;
case 1:
// this works fine, as do others
[self presentViewController:self.delegateRef.sensorsViewController animated:YES completion:nil];
break;
case 2:
...
}
/* savedRidesViewController */
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
}
Run Code Online (Sandbox Code Playgroud) 我推ViewController它含有不太多的意见,UIScrollView这里面包含10次,我有一个单身ViewController,没有再次释放和分配一次又一次地推ViewController,所以所有的事情,我在做viewDidLoad(),和viewWillAppear(),但动画是缓慢的,波涛汹涌,它可能是什么?
我提出了一个视图控制器:
SCAAboutController2 *controller = [[SCAAboutController2 alloc] initWithNibName:nil bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];
[self presentViewController:navController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
在呈现之前,设备会挂起3-4秒.我试图用仪器来诊断这个,但似乎大部分时间花在main-
这是相同的配置文件,但系统库取消隐藏:

这些消息都不是我能识别的,所以我不确定如何开始调试我的性能问题.
我在别处读到我应该检查主代码是否在主线程上执行.但是,以下更改并未改进任何内容:
dispatch_async(dispatch_get_main_queue(), ^{
SCAAboutController2 *controller = [[SCAAboutController2 alloc] initWithNibName:nil bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];
[self presentViewController:navController animated:YES completion:nil];
});
Run Code Online (Sandbox Code Playgroud)
我很快就没有关于如何进步的想法.我如何进一步调查,和/或可能是缓慢呈现的根本原因?
编辑
一些令人困惑的发现:
viewWillDisappear在呈现控制器中没有添加任何内容.编辑2
我发现问题集中在我在主(呈现)控制器中添加的一系列布局约束.具体来说,我遍历一些子控制器(类型teamController)并添加约束:
[self.browser addConstraint:[NSLayoutConstraint constraintWithItem:teamController.view
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
toItem:self.browser
attribute:NSLayoutAttributeWidth
multiplier:1
constant:0]];
Run Code Online (Sandbox Code Playgroud)
只有10个子控制器.同样奇怪:如果我使用以下代码,我就没有这样的问题了:
[self.browser.contentView addConstraint:[NSLayoutConstraint constraintWithItem:teamController.view
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
toItem:nil
attribute:NSLayoutAttributeNotAnAttribute
multiplier:1
constant:200]];
Run Code Online (Sandbox Code Playgroud)
我仍然非常困惑为什么这些约束会导致另一个模态的呈现挂起,以及为什么约束的一个变体表现出与另一个不同的显着不同.
我的目标是在第一个视图控制器中启动平滑动画,在第二个视图控制器中结束.
我正在尝试使用符合UIViewControllerAnimatedTransitioning和UIViewControllerTransitioningDelegate协议的对象的过渡动画 .我在故事板中设置了两个视图控制器(VC)并将它们与segue连接(默认显示).我还在第一个VC中展开了segue方法,并在第二个VC中为它设置了一个按钮.
我有奇怪的问题.我的对象有方法
func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
self.presenting = true
NSLog("start")
return self
}
func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
if presenting {
NSLog("Animation Push")
transitionPush(transitionContext)
}
else {
NSLog("Animation Pop")
transitionPop(transitionContext)
}
}
Run Code Online (Sandbox Code Playgroud)
我有两种不同的动画方法,从第一个VC到第二个VC,从第二个到第一个VC.当我激活segue时,我animationControllerForPresentedController和animateTransition方法之间有很奇怪的延迟.有时它可能是大约1秒,我的整个过渡动画必须是1秒加上这个意想不到的延迟太大了.这是一个日志:
2015-02-08 19:52:33.528 MyApp[1318:119598] start
2015-02-08 19:52:33.979 MyApp[1318:119598] Animation Push
Run Code Online (Sandbox Code Playgroud)
我不知道为什么会出现这种延迟,是否有办法删除或减少它?我试图检查这是否是我的代码,但我没有找到任何证据.随意询问更多信息.
ios ×3
iphone ×2
animation ×1
cocoa-touch ×1
instruments ×1
objective-c ×1
performance ×1
swift ×1
uitableview ×1