I have embedded a ScrollView within a UIViewController which contains multiple text fields that will act as a simple form to collect user data (Name, email, etc.). The problem is that when a text field is selected and the keyboard slides up, the text field is obscured by the keyboard. How can I slide the text fields back into view so that the user can clearly see what they are using as input?
You have to check for uikeyboard visibility ( see this post How can I programmatically check whether a keyboard is present in iOS app? ) and then call scrollRectToVisible for the selected textField. If you google about uikeyboard and scrollRectToVisible you will find many tutorial about this problem...
Related
I have a UIScrollView with 2 views, side by side, each of which covers the entire screen.
They are moved to visible bounds on user's action, only one covering the screen at a time. Both of these views have multiple UITextFields. Working with the simulator, I fill in a textField in the first view and when I press the Tab key, the firstResponder is assigned to a textField in the other view. I understand that on using the device, the user will not be able to do that. But what if the user uses a bluetooth keyboard, or similar accessory? I do not want a textField, that is currently not visible to become firstResponder. Can this be done?
EDIT: I just remembered the canBecomeFirstResponder method. But how do I determine which textField is about to becomeFirstResponder?
It sounds like the problem isn't that they shouldn't be able to tab between the two text fields, but instead that they shouldn't be able to edit a text field that isn't visible, and they should be able to tab between them if they are both visible at the same time.
Instead of restricting tab, I would implement the UITextField delegate method -textFieldShouldBeginEditing:, which allows you to return a boolean whether or not that text field should become the first responder.
Something such as:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
// Only edit if the text field is visible
return !textField.isHidden;
}
You may need to adjust this code to fit your 'is visible' status of the text field.
Can anyone suggest me, I am making an iphone app in which there is a text field where user has to select option from as list I have used tableView to show the list, and user select any one from them. But I want the text field as scroll Wheel where user can scroll the list inside the textfield and data get selected in the textfield when user stop scrolling as UIDatePicker does.
Please help me.
Since a UITextView is a subclass of UIScrollView, you should be able to create a UIScrollViewDelegate for your UITextView and implement scrollViewDidScroll:. Use the contentOffset to figure out what position the user has scrolled to.
I am developing a program in which I have UITextView in that I need a cursor without the key board.In this cursor is show only with the keyboard if I hide the keyboard cursor will also get hide.How can I get the cursor without the key board ?
The cursor is displayed as long as you UITextView is being edited.
Thus, you can change its inputView view to some other view if you need to, and it will be displayed instead of the keyboard.
See http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIResponder_Class/Reference/Reference.html
With this method you can add your custom inputView, a UIPickerView for example, or as you say you want you can add a minimalist hidden UIView.
If you want to restrict UITextField content, you still need to implement UITextFieldDelegate, as the user can still paste content to your text field!
I'm writing an app that has a view similar to the SMS app's text editing view. It has a textview on the top and a textfield on the bottom. I want to allow users to copy and paste texts in the textview while keeping the keyboard appear. But if I try to copy the text, the UITextField will resign first responder and the keyboard will missing. Any ideas about how can the SMS app keep the keyboard while user is copying texts in another view?
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
return NO;
}
I've tried to return NO for -(BOOL)textFieldShouldEndEditing: , but the textview to the upper cannot copy text then.
Related Option:
Just Give a button on Topbar or anywhere else that have option to copy the text then its more user friendly..
Second Option:
If you have much good know programming concepts then just create the new view above the keyboard and animate when keyboard is show and don't resignfirstresponder, and following options are their, copy text, done, in the done action you have resign first responder
Those are only option which u have done if you want more userfriendly app because in appStore and appReview Department have verify the User Convenience UI Integrations and you must full fill that and from the other side user's whom purchase or download the app also give the awesome comments on the app who is more reliable and cashless functionalities ....
I've tried to return NO for -(BOOL)textFieldShouldEndEditing: , but the textview to the upper cannot copy text then.
add a textfield so it can scroll and set the dimentions or just add the scrollbar to scroll it to .. it will solve your problem
i'm having one text field, normally when touch the text field, keyboard will appear, is it any possibilities where when text field is touch one drop down list will appear to recommend value to be enter and value is selected it will appear in texr field
thanks
There's no automatic way of doing it but it is possible.
You would use the textFieldDidBeginEditing: delegate method of the UITextField to display a UIPickerView to your view. (You could also use textFieldShouldBeginEditing: depending on what you wanted to do.) When a user selected an item in the picker, you would add code to copy the appropriate text to the text field and, presumably, hide or delete the picker. You'd also need to hide or delete the picker when the text field lost focus.