当用户点击它应该显示的表格视图的单元格时,我试图显示一个活动指示器vw,并且一旦加载详细视图,它就应该被隐藏。
但它在视图加载后显示然后隐藏。所以在视图加载时显示指示器是没有用的
内部viewdidload:
activityBgImageView = [[UIView alloc] initWithFrame:self.view.frame];
[activityBgImageView setBackgroundColor:[UIColor blackColor]];
[activityBgImageView setAlpha:0.7];
[activityBgImageView setCenter:self.view.center];
[activityBgImageView setHidden:YES];
activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[activityIndicatorView setCenter:CGPointMake(self.view.center.x+15, self.view.center.y-15)];
[activityIndicatorView setHidesWhenStopped:YES];
[activityBgImageView addSubview:activityIndicatorView];
[self.view addSubview:activityBgImageView];
这是我的表格代码选择:
if([arrPostsData count]>0)
{
[self startActivityIndicatorView];
[self performSelector:@selector(showDetailVw) withObject:nil];
}
-(void)showDetailVw
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.3];
detailVwBg.alpha = 0.0;
detailVwBg.alpha = 1.0;
btnBack.alpha = 1;
[self showPostDetail:arrPostsData tapedCell:detailvwScrollCount PostedFiles:arrUserPostedFilesDataDic comments:arrCommentsDataDic];
isDetailvwActive = TRUE;
[UIView commitAnimations];
}
and inside showPostDetail: method end i stop the indicator
请建议我需要在哪里放置正确的代码
这些是指标方法:
#pragma mark processindicator methods
-(void)startActivityIndicatorView{
[activityBgImageView setHidden:NO];
[activityIndicatorView startAnimating];
[self.view bringSubviewToFront:activityBgImageView];
if (![[UIApplication sharedApplication] isIgnoringInteractionEvents])
{
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
}
}
-(void)stopActivityIndicatorView{
if ([[UIApplication sharedApplication] isIgnoringInteractionEvents])
{
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
}
[activityBgImageView setHidden:YES];
[activityIndicatorView stopAnimating];
}