PDA

View Full Version : Transfer Focus to Next UITextField




rupesh.swami
Mar 9, 2009, 03:55 AM
hi all,
i am newBie to iPhone Programming

I want to whenever user Press return Key in any UITextField then focus transfer to Next UITextField

Also how can i make UITextField to Read Only. so user can not type anything in UITextField



sujithkrishnan
Mar 12, 2009, 06:54 AM
In - (BOOL)textFieldShouldReturn:(UITextField *)textField this method before returning yes,textField on which u want to focus just call becomeFirstResponder
For eample if u have two textfields firstname,lastname if ur in editing mode of firstname when u hit return then just comapre if([textField isEqual:firstname])
if it is true then [lastName becomeFirstResponder].
If u want readOnly then set userInteractionEnabled to NO

dejo
Mar 12, 2009, 10:22 AM
If u want readOnly then set userInteractionEnabled to NO
Actually, the property is named "enabled" (if accessing via code) but appears as "User Interaction Enabled" in Interface Builder.

jnic
Mar 12, 2009, 10:32 AM
UITextField inherits from UIView so will respond to userInteractionEnabled (https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instp/UIView/userInteractionEnabled).

dejo
Mar 12, 2009, 10:39 AM
UITextField inherits from UIView so will respond to userInteractionEnabled (https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instp/UIView/userInteractionEnabled).
Ah, sorry about that. I was looking at UITextField's parent class, which is UIControl which has an enabled (http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIControl_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006779-RH2-SW17) property. Since Apple changed the name in this class, I supsect there may be differences in which one you use.