Да, вы можете сделать расчет кадра или любую другую логику на заднем плане. Но операции с пользовательским интерфейсом, такие как добавление subview, анимация, должны быть в основном потоке.
CGPoint annPoint = [self.mapView convertCoordinate:coord toPointToView:self.mapView];
mapPic = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pic.png"]];
mapPic.frame = CGRectMake(annPoint.x, annPoint.y, 32, 32);
[self.view addSubview:macPic];
его можно записать согласно вашему требованию:
- (void)doCalculation
{
//you can use any string instead "com.mycompany.myqueue"
dispatch_queue_t backgroundQueue = dispatch_queue_create("com.mycompany.myqueue", 0);
dispatch_async(backgroundQueue, ^{
CGPoint annPoint = [self.mapView convertCoordinate:coord toPointToView:self.mapView];
mapPic = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pic.png"]];
mapPic.frame = CGRectMake(annPoint.x, annPoint.y, 32, 32);
dispatch_async(dispatch_get_main_queue(), ^{
[self.view addSubview:macPic];
});
});
}
надеюсь, что это поможет
// логика может быть написана на фоне threadCGPoint StartPoint = [ffMapView convertCoordinate: startCoordinate toPointToView: самостоятельно. Посмотреть]; , но окончательный выход, как добавить subview или просмотр анимации, должен быть в главной теме – Alok