我有一个带有calloutAccessoryControl的MKAnnotation。按下时,我显示一个UIView:
-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
NSDate *start = [NSDate date];
DLog(@"fired");
DLog(@"thread: %@", [NSThread currentThread]);
EntityPoint *entityPoint = (EntityPoint *)view.annotation;
EntityFormView *entityFormView = entityPoint.entityFormView;
DLog(@"addind subview: %f", [[NSDate date] timeIntervalSinceDate:start]);
[self.view addSubview:entityFormView.screenView];
DLog(@"addind constraints: %f", [[NSDate date] timeIntervalSinceDate:start]);
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[screenView]|" options:0 metrics:nil views:@{@"screenView": entityFormView.screenView}]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[screenView]|" options:0 metrics:nil views:@{@"screenView": entityFormView.screenView}]];
DLog(@"finished , doing animation: %f", [[NSDate date] timeIntervalSinceDate:start]);
[UIView animateWithDuration:.1
animations:^{
entityFormView.screenView.alpha = 1;
}
completion:^(BOOL finished) {
DLog(@"completely finished: %f", [[NSDate date] timeIntervalSinceDate:start]);
}];
}
我第一次运行此代码时,它发生在〜.2秒内。我关闭它然后重新打开它需要~1.2秒:
DEBUG | -[MapViewController mapView:annotationView:calloutAccessoryControlTapped:] | fired
DEBUG | -[MapViewController mapView:annotationView:calloutAccessoryControlTapped:] | thread: <NSThread: 0x1d548bc0>{name = (null), num = 1}
DEBUG | -[MapViewController mapView:annotationView:calloutAccessoryControlTapped:] | addind subview: 0.005463
DEBUG | -[MapViewController mapView:annotationView:calloutAccessoryControlTapped:] | addind constraints: 0.047544
DEBUG | -[MapViewController mapView:annotationView:calloutAccessoryControlTapped:] | finished , doing animation: 0.049323
DEBUG | __74-[MapViewController mapView:annotationView:calloutAccessoryControlTapped:]_block_invoke1001 | completely finished: 0.199709
DEBUG | -[MapViewController mapView:annotationView:calloutAccessoryControlTapped:] | fired
DEBUG | -[MapViewController mapView:annotationView:calloutAccessoryControlTapped:] | thread: <NSThread: 0x1d548bc0>{name = (null), num = 1}
DEBUG | -[MapViewController mapView:annotationView:calloutAccessoryControlTapped:] | addind subview: 0.006285
DEBUG | -[MapViewController mapView:annotationView:calloutAccessoryControlTapped:] | addind constraints: 1.069605
DEBUG | -[MapViewController mapView:annotationView:calloutAccessoryControlTapped:] | finished , doing animation: 1.082836
DEBUG | __74-[MapViewController mapView:annotationView:calloutAccessoryControlTapped:]_block_invoke1001 | completely finished: 1.194132
当我删除UIView时:
-(void)removeForm {
[UIView animateWithDuration:.1
animations:^{
self.screenView.alpha = 0;
}
completion:^(BOOL finished) {
[self.screenView removeFromSuperview];
}];
}
为什么在第一次使用这么长时间后添加subView? /折流
答案 0 :(得分:0)
它有点像第一次运行,alpha动画没有发生,这很奇怪。在completely finished
日志之后,您的完成doing animation
日志应加上大约1秒的时间戳。我会说开始在那里进行调查,因为这是事件序列中看起来不正确的第一件事。也许当它第一次运行时,UIView的alpha已经是1.0,所以它不会淡入?
答案 1 :(得分:0)
我玩弄它并在解决我遇到的另一个问题时,我也解决了这个问题。
表单视图是一个子类UIScrollView
,要关闭视图,您需要向下滚动才能单击“保存”按钮。这会导致contentOffset
设置为145.关闭后,我将contentOffset
设置为0.这解决了我的慢显示问题。
我最好的猜测是UIScrollView
动画到偏移,而alpha仍为0.一旦它动画到偏移量,它会将alpha动画设为1。