我正在开发一个 ios 应用程序。我在视图上使用此代码,以便在加载时使活动指示器和黑色背景出现在整个视图的位置。
// hiding all the uioutlet in the view
sfondo.hidden=TRUE;
dalText.hidden=TRUE;
alText.hidden=TRUE;
titoloText.hidden=TRUE;
// generating the activity indicator
CGRect screenBound = [[UIScreen mainScreen] bounds];
CGSize screenSize = screenBound.size;
CGFloat screenWidth = screenSize.width;
CGFloat screenHeight = screenSize.height;
imgCaricamento = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[imgCaricamento setCenter:CGPointMake(screenWidth/2.0, screenHeight/2.0)]; // I do this because I'm in landscape mode
[self.view addSubview:imgCaricamento]; // spinner is not visible until started
[imgCaricamento startAnimating]; // start!
现在的问题是我在开始更新之前启动了这段代码并做了几件事。发生的情况是,在启动此代码时,视图会冻结一两秒,只有在此延迟时间之后,活动才会出现。这一次足以向用户传达应用程序表现不佳的印象......我怎样才能让这段代码在之前和立即执行?