PDA

View Full Version : Create tool bar for UITextField which show Previous Next and Done button




rupesh.swami
Apr 1, 2009, 08:27 AM
hi all,
i am new to iPhone programming,
in Safari browser(iPhone), when we navigate a page which contain multiple user entry field (related to UITextField), then it display a toolbar which contains Previous,Next and done button and click on these buttons facilitate us to navigate between these user entry fields.
How can i make this object or whether IB contains this type of object?



johnnyjibbs
Apr 1, 2009, 11:25 AM
I would create a toolbar (UIToolbar) and then set the next and back buttons (or whatever you want) as items on the toolbar.

Something like:

[toolbar setItems:[NSArray arrayWithObjects:backButton,flexSpace,nextButton,nil] animated:NO]

where backButton and nextButton are UIBarButton objects. The flexSpace is also a UIBarButton but a special type that would mean your buttons are on the left and the right of the toolbar. In the above example, 'toolbar' is an instance of UIToolbar that has already been created.

You may be able to create toolbars using Interface Builder but you will need to programmatically move them in time with the keyboard using Core Animation. The animation code would need to be executed when the text field in question becomes the first responder.

To be honest, I think you need to try out some example code on more simple techniques before getting too much into this kind of thing at this stage.

rupesh.swami
Apr 2, 2009, 02:49 AM
I would create a toolbar (UIToolbar) and then set the next and back buttons (or whatever you want) as items on the toolbar.

Something like:

[toolbar setItems:[NSArray arrayWithObjects:backButton,flexSpace,nextButton,nil] animated:NO]

where backButton and nextButton are UIBarButton objects. The flexSpace is also a UIBarButton but a special type that would mean your buttons are on the left and the right of the toolbar. In the above example, 'toolbar' is an instance of UIToolbar that has already been created.

You may be able to create toolbars using Interface Builder but you will need to programmatically move them in time with the keyboard using Core Animation. The animation code would need to be executed when the text field in question becomes the first responder.

To be honest, I think you need to try out some example code on more simple techniques before getting too much into this kind of thing at this stage.


but i think this approach require create toolbar for each view in my application and reposition the view manually on click of Previous and Next button

johnnyjibbs
Apr 2, 2009, 04:02 AM
The problem is that you can't access the keyboard API (as far as I know), although it does give out height notifications which you can do to ensure you toolbar is always in the right place in relation to the keyboard.

If you were allowed to access and subclass the keyboard API you could make a custom version, complete with Previous and Next buttons, but as far as I know this is not possible - at the moment at least.

You could create a template view controller that handles all the text fields so that you would only have to program it once.