2014-02-26 47 views
0

我試圖顯示一個活動指標以及navigationItem.titleView中的文字「連接」。iOS顯示導航項目標題中的活動指標和文本連接?

我已經設法通過活動指示器顯示,但不顯示文本。

我當前的代碼:

self.navigationItem.titleView = nil; 

UIActivityIndicatorView *aiView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; 
aiView.hidesWhenStopped = NO; 
self.navigationItem.titleView = aiView; 

任何想法如何做到這一點?

回答

1

嘗試以下...

// first create main view 
UIView *mainView = [[UIView alloc] initWithFrame:..... 

// now lets create label that you need to display 
UILabel *titleLabel = [[UILabel alloc] initWithFrame:..... 
titleLabel.text = @"Title here"; 
[mainView addSubview:titleLabel]; 

// now create indicator 
UIActivityIndicatorView *indicator = initWithFrame:..... 
[mainView addSubview:indicator]; 


// now add mainView to titleView 
self.navigationItem.titleView = mainView; 
相關問題