How to move to next screen on click of Read only text field iOS - ios

I have a textfield that is readonly. I have another Search View Controller(VC) also. My aim is when the user clicks on readonly textfield it should open the searchVC. I tried attaching Push seque to SearchVC but it's not working. Tried same with a button and works seamlessly.
Pls suggest whats the approach for this.

You can use gesture to your textfield
or
You can use custom button above the textfield. You have to show/hide the button on textfield disabled/enabled

try this
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
if (textField.tag==1)
{
//write alert view to check "click on this text filed alert is appearing"
return NO;
}
else if (textField.tag==2)
{
//it's behave normal uitextfiled
return YES;
}
}

Related

Working with textfieldShouldReturn() for two TextBox

Hi I started to learning iOS developing but in my first I got a problem
I have two Text box in first one when I press return button on keyboard go
to next text box I did it well but the problem is this when I am on the second Text box I want after typing when I press return keyboard go away
I cant use two
textfieldShouldReturn()
You can tell which text box is being called. First, you need to create outlets so that you can reference the two text boxes by name. Then:
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
if (textField == self.firstTextField) {
// Do it one way
} else if (textField == self.secondTextField) {
// Do it another way
}
return NO;
}

How to associate iOS keyboard "go" button with UIButton?

I have a search bar in my SearchViewController, and currently, when they type into it, there's no Go button, it shows only return. I want a Go button to show in the keyboard, and I want it to be connected to the - (IBAction)nextButton:(id)sender that I have connected to the existing next UIButton under the search bar.
How do I go about enabling this and connecting it in this way? To clarify, the search bar and next button were created in storyboard, not programmatically.
[textField setReturnKeyType:UIReturnKeyGo];
or
- (void)setReturnKey {
//use condition here(not empty field)
self.searchField.returnKeyType = UIReturnKeyGo;
}
the other thing as Ghobs said you can find here...
- (BOOL) textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];//Dismiss the keyboard.
//Add action you want to call here.
return YES;
}
source for above code:Action of the "Go" button of the ios keyboard
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIReturnKeyType

objective c textField: selectAll text doesn't always work

I implemented this in the UITextField delegate:
-(void)textFieldDidBeginEditing:(UITextField *)iTextField {
[iTextField selectAll:iTextField];
}
My text field contain text.
When tapping on it, the keyboard goes up and all text selected.
when dismissing the keyboard and tapping again, no text selected (just blinking cursor).
when dismissing the keyboard and tapping again, all text selected again.
Any clue why does no text selected at the second tap?
have you tried with this?
textField.selectedTextRange = [textField textRangeFromPosition:textField.beginningOfDocument toPosition:textField.endOfDocument];
EDIT 1:
Now is going to work :), this call will be at the end of the queue
[textField performSelector:#selector(selectAll:) withObject:nil afterDelay:0.0];
I call selectAll in viewDidAppear works.

picker wheel that only appears when selected

I have a view controller that displays various UITextfields to edit information. For one UITextfield I need a picker wheel to select predefined statuses.
Problem is I don't have enough space to integrate a picker wheel, is there a possibility to make it appear only when the text box is selected?
You could set the UIPickerView as the UITextField's inputView.
This will ensure that the picker is shown automatically when the text field gets focus, and hides it when lost.
E.g.
myTextField.inputView = self.myPickerView;
See the documentation on this property.
Assuming your "picker wheel" is a UIView, just hook up your controller as the UITextField's delegate and implement the following:
- (void)textFieldDidBeginEditing:(UITextField *)textField {
self.pickerWheel.hidden = NO;
}
You need to call your UIPicker in (BOOL)textFieldShouldBeginEditing:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
if (textField==self.yourtextfield) {
//call your wheel in here
}
}
Look at
How to Show UIPickerView when selecting UITextField

Force keyboard to show up via button (iOS)

I have an UITextView and I don't want check editable option, how can call keyboard via a button?
This code doesn't work for me!
-(IBAction) yourButtonClick
{
[myTextView becomeFirstResponder];
[self.view addSubview:myTextView];
}
From the iPhone Application Programming Guide
However, you can programmatically
display the keyboard for an editable
text view by calling that view’s
becomeFirstResponder method. Calling
this method makes the target view the
first responder and begins the editing
process just as if the user had tapped
on the view.
So to show the keyboard programmatically,
[textView becomeFirstResponder];
However, the keyboard will never show if the textView is not editable.
The purpose of showing the keyboard is to allow editing. I assume you just don't want the keyboard to appear when the user taps the text view. In this case, you can enable editable programmatically when the button is tapped.
-(IBAction) yourButtonClick
{
myText.editable = YES;
[myText becomeFirstResponder];
}
Then in the UITextViewDelegate, disable editable when the user finishes editing.
- (void)textViewDidEndEditing:(UITextView *)textView {
textView.editable = NO;
}

Resources