2013-04-12 48 views
0

我在故事板應用程序中有一個UIViewController。當SEGUE設置,我已經從IB增加了UIToolBar的底部會自動添加調整UIViewController中的視圖

enter image description here

導航欄。

在運行時,UIScrollView作爲視圖添加到視圖控制器。造成的問題與之前添加的UIToolBar重疊。於是我添加了下面的行,並將工具欄拉回到前面。

self.mailOptionsToolbar.layer.zPosition = 1; 

現在看起來不錯,但仍然有一個小問題。當我點擊UIToolBar中的工具欄按鈕項時,它們就不起作用。比如說,在滾動視圖中,如果有UITextbox放置在這些按鈕的下面,當我點擊它們時,它會彈出鍵盤!它的點擊正在通過UIToolBar到達下面的UITextField。我怎樣才能阻止這種情況發生?

我想到了另一種方式。這是調整UIScrollBar以適應只有白色間隔區域,以便它不會掩蓋UIToolBar首先,因此不會產生此點擊問題。但我不知道如何使在運行時添加的UIScrollView僅適合白色區域。

對這兩個建議將不勝感激。

謝謝。

回答

1
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height; 
    // 20.0f is for status bar height and 44.0f is for navigation bar 
    CGFloat scrollViewHeight = screenHeight - 20.0f - 44.0f - self.mailOptionsToolbar.frame.size.height; 
    CGRect frame = [CGRectMake(0, 0, 320.0f, scrollViewHeight)]; 
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:frame]; 
相關問題