1

我有一个 mapView (_mapView),它本身就是我的 viewController 的一个子视图,我想在获取很多引脚时添加一个 activityIndi​​cator,但是我不能让它出现在 mapView 上方,谁能建议为什么不

 UIActivityIndicatorView *activityIndicator = nil;
    activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] ;
    CGRect frame = activityIndicator.frame;
    frame.origin = CGPointMake(290, 12);
    activityIndicator.frame = frame;
    activityIndicator.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
    activityIndicator.tag = 2;
    [self._mapView addSubview:activityIndicator];
dataMarkers = [[kepnService new] getPlacesByBounds:neCoord.latitude :neCoord.longitude :swCoord.latitude :swCoord.longitude]; // call to webservice
.... other processing code
 [activityIndicator removeFromSuperview]; 

有关信息,我的视图堆栈如下所示

subviews (
    "<MKMapView: 0x6d6f320; frame = (0 0; 320 460); clipsToBounds = YES; layer = <CALayer: 0x6d99520>>",
    "<UIToolbar: 0x6d93f70; frame = (-1 0; 342 44); autoresize = W+TM; layer = <CALayer: 0x6d8bbf0>>",
    "<UINavigationBar: 0x6d9a4f0; frame = (0 416; 320 44); autoresize = W+BM; layer = <CALayer: 0x6d9a5b0>>"
)
4

1 回答 1

1

好像您正在添加活动指示器,阻塞主线程然后将其删除。

你应该做的是:

添加活动指示器。将线程或块分离到后台以执行处理代码。完成后,移除活动指示器。

于 2012-05-22T05:08:46.597 回答