How to present keyboard inside popover?, ipad passcode lock style - ipad

Is it posible to present a keyboard the way is shown when you set a passcode for your ipad?

Unfortunately no, But what i did to replicate this was, built a bunch of buttons like a keyboard inside my passcode view using interface builder. Then linked each button to a command that would change the text field.
- (IBAction) button9_clicked:(id) sender{
if ([self textField:theTextField shouldChangeCharactersInRange:range replacementString:#"9"]){
self.theTextField.text=[self.theTextField.text stringByAppendingString:#"9"];
range.location = self.theTextField.text.length;
}
else
range.location = self.theTextField.text.length;
}

Related

Removing Keyboard Top Bar [duplicate]

I'm trying to update an app for iOS8, which has a chat interface, but the new Quicktype keyboard hides the text view, so I would like to turn it off programmatically or in interface builder.
Is it possible somehow or only the users can turn it off in the device settings?
I know there is a question/answer which solves this problem with a UITextfield, but I need to do it with a UITextView.
You may disable the keyboard suggestions / autocomplete / QuickType for a UITextView which can block the text on smaller screens like the 4S as shown in this example
with the following line:
myTextView.autocorrectionType = UITextAutocorrectionTypeNo;
And further if youd like to do this only on a specific screen such as targeting the 4S
if([[UIDevice currentDevice]userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
if (screenHeight == 568) {
// iphone 5 screen
}
else if (screenHeight < 568) {
// smaller than iphone 5 screen thus 4s
}
}
For completeness sake I would like to add that you can also do this in the Interface Builder.
To disable Keyboard Suggestions on UITextField or UITextView — in the Attributes Inspector set Correction to No .
I've created a UITextView category class with the following method:
- (void)disableQuickTypeBar:(BOOL)disable
{
self.autocorrectionType = disable ? UITextAutocorrectionTypeNo : UITextAutocorrectionTypeDefault;
if (self.isFirstResponder) {
[self resignFirstResponder];
[self becomeFirstResponder];
}
}
I wish there was a cleaner approach tho. Also, it assumes the auto-correction mode was Default, which may not be always true for every text view.
In Swift 2:
myUITextField.autocorrectionType = UITextAutocorrectionType.No
In Swift 4.x:
myUTTextField.autocorrectionType = .no
As others have said, you can use:
textView.autocorrectionType = .no
but I've also noticed people struggling with actually making the autocomplete bar swap out, since if the textView is already the firstResponder when you change its autocorrectionType, it won't update the keyboard. Instead of trying to resign and reassign the firstResponder status to the textView to effect the change, you can simply call:
textView.reloadInputViews()
and that should hide the autocomplete bar. See https://developer.apple.com/documentation/uikit/uiresponder/1621110-reloadinputviews

UITextField animate input view frame animated

I am developing an application that displays a custom Keyboard (similar to Messenger's) (containing images).
I have been asked to add a button that changes the frame of the keyboard with an animation. But when i set the frame it does not change at all.
Is this possible to do ? Could this be done nicely or do i need some work around ?
You can use inputView Property Of TextField,
UITextField *textFieldWithCustomView;
UIView *customView;
[textFieldWithCustomView setInputView:customView];
and when you want to expand/Collapse use
- (void)toggleCustomView:(BOOL)expand
{
if (expand) {
[textFieldWithCustomView becomeFirstResponder];
}
else
{
[textFieldWithCustomView resignFirstResponder];
}
}
When you want to show key board use
[self toggleCustomView:YES];
Hope this helps.

Tabbing uiTextFields like in simulator

I am building a forms based application and i have noticed that while in the simulator using the hardware mac keyboard i am able to tab between form fields in a table using the standard tab key.
Is there a way i can call this functionality from my TextView when the didReturn method is fired? I have seen numerous threads on here with various ways to achieve something similar but they all seem overly complex and bulky using view tags for big loops which is not ideal compared to perhaps just firing a TAB keyboard command?
All you need to do is set a nextButton on your view, or inputAccessoryView for all the textFields and on selector of that button write code to make nextTextField a first responder.
By this way you can implement that tab feature. As you know there's no tab button on your iPhone ;).
You can do it via UITextField delegate method:
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
NSInteger nextTag = textField.tag+1;
UIResponder* nextResponder = [textField.superview viewWithTag:nextTag];
if (nextResponder) {
[nextResponder becomeFirstResponder];
}
else {
// Do what ever want to do for last textfield
[textField resignFirstResponder];
}
return NO;
}
Set you textfields tag, sequentially & set delegate. Pressing return key in for moving to next textfield.
Hope this helps.. :)

How to move to next screen on click of Read only text field 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;
}
}

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