我在Storyboard中創建了一個UITableViewController
,然後將一個Activity Indicator View拖動到控制器中(併爲它創建了一個出口),在一些json內容加載之前和之後開始和停止動畫。居中活動指標查看到UITableView
我可以看到ajax spinner工作正常,但它直觀地顯示在我的導航器/標題區域下方,當我試圖居中時,它顯示居中寬度明智,出現在最靠近狀態區域的頂部。 。
我嘗試,企圖居中下面......下面就讓我們來看看我viewDidLoad
:
- (void)viewDidLoad
{
[super viewDidLoad];
self.listLoader.center = CGPointMake([UIScreen mainScreen].bounds.size.width/2,[UIScreen mainScreen].bounds.size.height/2);
UITableView *appDelegate = (UITableView *)[[UIApplication sharedApplication] delegate];
[appDelegate.window addSubview:self.listLoader];
self.operationQueue = [NSOperationQueue new];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(getPosts) object:nil];
[self.operationQueue addOperation:operation];
}
請注意,我的兩個startAnimating
和stopAnimating
載我getPosts
方法中和執行在主線程上。所以,爲了避免混淆,我實際上可以看到微調,它只是進入狀態區。事實上,如果我刪除線......似乎
self.listLoader.center = CGPointMake([UIScreen mainScreen].bounds.size.width/2,[UIScreen mainScreen].bounds.size.height/2);
UITableView *appDelegate = (UITableView *)[[UIApplication sharedApplication] delegate];
[appDelegate.window addSubview:self.listLoader];
的微調,導航欄的正下方...
究竟如何我中心這個???我想上面的方法可以工作,但顯然它不工作....
嘗試在viewWillAppear中設置您的居中核心。看看它是否有效,我經常遇到元素加載時遇到的麻煩,這些元素以我期望加載的不同方式加載。 – Pochi
嘗試過,但它看起來像我在viewDidLoad中保持居中一樣。 –