我正在尋找一種方式來展示我的當前UIViewController上的模態視圖,基本上顯示一個UIActivityIndicator並強制用戶在數據加載時等待。iOS切換到背景UIViewController
在BaseViewController.m(基類我所有UIViewControllers的):
// show loading view
-(void) showLoading
{
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
LoadingViewController *loading = [storyBoard instantiateViewControllerWithIdentifier:@"loadingView"];
loading.view.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:0.7];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:loading animated:NO completion:nil];
}
這個偉大的工程,但我怎麼能回去裝載後視圖背景視圖應該怎麼辦?
需要一個stopLoading方法回到原來的觀點:
// stop loading
-(void) stopLoading
{
// code here
}
如果我嘗試我介紹了加載視圖像這樣後,提出一個新的觀點:
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
UIViewController *view = [storyBoard instantiateViewControllerWithIdentifier:@"loadingView"];
[self presentViewController:view animated:YES completion:nil];
使用調試器警告:
Attempt to present PropertyPickerViewController: 0x8af6010 on ViewController: 0x8ab23c0 which is already presenting LoadingViewController: 0x8acf530
。
那麼,gif是一個UIActivityIndicator。我會編輯我的問題來描述。此外,這工作完美。我會盡快接受答覆。 –
+1替代答案:) –