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]);
}];
}
このコードを初めて実行すると、約 0.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];
}];
}
初めて時間がかかった後にサブビューを追加するのはなぜですか? /困惑