2011-08-27 94 views

回答

1

[TexfieldName becomeFirstResponder];在viewDidLoad中的secondViewController。

這將專注於特定的文本框,並顯示鍵盤。

+0

我不想將焦點設置到它的視圖加載時。但只有當我的secondViewController彈出。 – John

+0

然後使用viewWillAppear中 – iProgrammer

+0

我不能這樣做,因爲它會影響其他的東西。我只希望它能夠在我的secondViewController彈出時特別設置焦點。我的意思是,在我的secondViewController彈出之前(firstViewController將會顯示),我需要將焦點設置在FirstViewController中的UITextField上。 – John

0

如果你不想使用viewWillAppear:,你可以使用UINavigationControllerDelegate方法– navigationController:willShowViewController:animated:,並改爲調用你的方法。

只要確保某個類是您的導航控制器的delegate,並讓它調用firstViewController調用becomeFirstResponder的方法。

編輯:鏈接到UINavigationControllerDelegate蘋果文檔。