3

I got a simple detail view with a textfield. In detail's viewController I wrote this code:

- (void) viewDidAppear:(BOOL)animated{
    [self.textField becomeFirstResponder];
    NSLog(@"is textField 1st responder %d", [self.textField isFirstResponder]);
}

When I push the detail into a navigation controller, I see "is textField 1st responder 0" in my log. The keyboard doesn't appear. But the textfield has blinking cursor.

What happens in this moment? Why the keyboard doesn't appears? I did try to catch a notification "KeyboardDidShown" in my AppDelegate but didn't catch anything: enter image description here

Here is my master view design :

enter image description here

kas-kad
  • 3,736
  • 1
  • 26
  • 45
  • Are you sure that `self.textField` isn't `nil` and is already on your view when you call `becomeFirstResponder`? – Andreas Ley Dec 19 '12 at 20:23
  • I've just tried to move this code to viewDidLoad method - nothing changes. – kas-kad Dec 19 '12 at 20:27
  • That doesn't answer my question. :) Where do you initialize your `UITextField` and where do you add it to your `UIView`? – Andreas Ley Dec 19 '12 at 20:29
  • Where are you setting the UITextFieldDelegate? – DenVog Dec 19 '12 at 20:36
  • Andreas, I initialize the textField in IB. – kas-kad Dec 19 '12 at 21:12
  • DenVog, I don't use textField delegation. Keyboard should appears without the delegation. Am I wrong? – kas-kad Dec 19 '12 at 21:14
  • You picked the bellow answer as "The Correct Answer" but it is so vague. I have the same problem but can't figure out how to solve it. The codes in rghost are deleted. This community is for helping all people not only yourself. Please make the answer more clear. – AliBZ Mar 21 '13 at 17:44
  • @AliBZ i've edited the answer, but it may be invisible atm. so here you go - two projects: solved http://dl.dropbox.com/u/34188625/hh2_Solved.zip and the original one with bugs http://dl.dropbox.com/u/34188625/hh2.zip . You can check that the keyboard doesn't appears at detail view (you create some row on master view before) – kas-kad Mar 22 '13 at 13:03

1 Answers1

3

Does calling reloadInputViews help?

Akshay Shah
  • 1,120
  • 6
  • 13
  • "If the current object is not the first responder, this method has no effect." the problem is - I can't find where is my first responder. I've checked all views with this method `- (void) viewDidAppear:(BOOL)animated{ NSLog(@"is view 1st responder %d", [self isFirstResponder]); }` – kas-kad Dec 20 '12 at 12:21
  • I've tried to send `reloadInputViews` to my textField in viewDidAppear but nothing happens – kas-kad Dec 20 '12 at 12:37
  • Can you send the project? May be a sample one showing the issue. – Akshay Shah Dec 20 '12 at 12:44
  • That is solved now... :) The reason for the issue was that you had two different UIWindow objects. One - in your app delegate Two - in your view controller xib. Here instead of uiwindow it should had been UIView. and in its viewDidLoad add TabBarview. You can download the solved project at : http://rghost.net/42397367 – Akshay Shah Dec 21 '12 at 06:24