2015-12-17 122 views
1

我在這裏遇到了一些問題。對於我的應用程序,我有我的主要觀點,針對不同的窗口。我已經把它們放在視線範圍內,當它們被需要的時候,它們被動態地移動到視圖中,直到我決定創建一個文本域時,我從來沒有遇到過這個問題。當我點擊按鈕來顯示視圖時,它會出現,但是當我單擊文本框來鍵入並且鍵盤加載視圖消失時,但是如果我單擊按鈕以使視圖返回,文本框將被輸入並準備就緒輸入。任何人都有解決辦法我附上了視圖出現方式下面的代碼。iOS鍵盤製作視圖消失

感謝,

CurtisB

- (IBAction)login:(id)sender { 

    sidebutton = @"0"; 
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:0.0]; 
    [self.blackhide setFrame:CGRectMake(self.blackhide.frame.origin.x -750, self.blackhide.frame.origin.y, self.blackhide.frame.size.width, self.blackhide.frame.size.height)]; 
    [UIView setAnimationDuration:0.5]; 
    [self.button2 setFrame:CGRectMake(self.button2.frame.origin.x - 300, self.button2.frame.origin.y, self.button2.frame.size.width, self.button2.frame.size.height)]; 
    [self.mainview setFrame:CGRectMake(self.mainview.frame.origin.x - 300, self.mainview.frame.origin.y, self.mainview.frame.size.width, self.mainview.frame.size.height)]; 
    [self.sidebarview setFrame:CGRectMake(self.sidebarview.frame.origin.x - 376, self.sidebarview.frame.origin.y, self.sidebarview.frame.size.width, self.sidebarview.frame.size.height)]; 
    [UIView setAnimationDuration:0.0]; 
    [self.loginview setFrame:CGRectMake(self.loginview.frame.origin.x + 376, self.loginview.frame.origin.y, self.loginview.frame.size.width, self.loginview.frame.size.height)]; 
} 
+0

多放些代碼,即您使用文本框 – NSPratik

+0

塊做什麼。根據。動畫。以來。 iOS4的。請。謝謝。您。 – holex

回答

1

嘗試使用下面的代碼,使頂部到前你想要的subview

[parentView bringSubviewToFront:childView]; 

例如,如果你想顯示VIEW_A,每當你隱藏該視圖時,都要執行該代碼。如果你仍然得到這個問題,把這些代碼時鍵盤UITextfield委託方法出現,即..

添加評論,如果你還停留..

+0

謝謝,這似乎是最好的解決方案。 –

+0

它是否適用於您? – NSPratik

+0

是的,得到它排序謝謝。 –