On 25/08/2009, at 20:42 , Georg C. Brückmann wrote:

On 25.08.2009, at 12:30, Brian Bruinewoud wrote:

I have a simple view that contains a UITextField and a UIButton. The user will most often want to type text and ignore the button. Is there some way I can make the keyboard appear immediately that view is shown? I can't find anything in IB and reading about UITextField, UIView, UIWindow, UIResponder didn't enlighten me.

-[UIResponder becomeFirstResponder], e. g.:

- (void)viewDidLoad {
  [super viewDidLoad];
  [_myTextFieldOutlet becomeFirstResponder];
}

Actually, that's not correct, but while I was checking that I noticed that its documentation said

"Use the NSWindow makeFirstResponder: method, not this method, to make an object the first responder. Never invoke this method directly."

But There is no NSWindow on iPhone.

So far I've tried:

    [ self.textField makeFirstResponder ];

    [ self makeFirstResponder: textField ];

UIWindow *win = [((AppDelegate*)[[ UIApplication sharedApplication ] delegate ]) window ];
    [ win makeFirstResponder: self. textField ]

They all complain about the object "may not respond to '- makeFirstResponder'"

Brian._______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to