UIPopoverView follow uitextfield cursor - ios

So I am trying to implement autocomplete suggestion in a UIPopoverView over a UItextField. My only problem is how to get to popover to point to the suggested word or at least to the end of the text in the textfield.
I believe the key here is the sourcerect property but when set to the uitextfield it always points the center of the textfield.

You can find the position of the last text in the UITextfield with
let endPosition: UITextPosition = textField.endOfDocument
Try to set the popover source to it.

Related

How to change the caret/cursor size of a UISearchBar in Swift?

I know that the caret rect of a UITextView or UITextField can be changed by overriding the caretRectForPosition method, but I can't figure out how to do the same for a UISearchBar. Is this possible?

Not properly add inputAccessoryView for UITextField

There is a requirement of inputAccessoryView is for the chat application.
When I add inputAccessoryView to UITextField on tap event of UIButton. That view is set as inputAccessoryView completely but text field is not becoming first responder.
(Note: Super view of textfield is viewText.)
- (IBAction)btnOpenTextField:(id)sender
{
UIView *accessoryView=[[UIView alloc]init];
accessoryView.frame=CGRectMake(0,0, _viewText.frame.size.width, _viewText.frame.size.height);
[accessoryView addSubview:_viewText];
_txtMessage.inputAccessoryView = accessoryView;
[_txtMessage becomeFirstResponder];
}
Thanks in Advance.
You can call [_textMessage reloadInputViews], replacing [_text becomeFirstResponder].
What you want to achieve is quite not possible, this will cause recursion, alternatively what you can do is put a textfield on bottom of the screen and when the textfield is selected you can animate it up with the flow of the keyboard. i think this is an appropriate solution if i got your question correctly.

How to set keyboard as inputview in UItextfiled

I have one UItextfiled and in viewdidload i set his input view property as nil like this.
textField.inputView = nil
In in my view i have one button when i click on the button i have to set the textfield's inputview property as keyboard how can i do this.please help me.
I'm not exactly sure what you want to do, but probably you want your textField to became active, with a keyboard. That is done with
[textField becameFirstResponder];
and other way around is
[textField resignFirstResponder];

Customising the Text Field

So - I am experimenting at the moment with app design.
This is my concept:
See the blue line? That should be where the users "cursor" starts and cant go negativaly behind that point, but can move positively until the end of the box.
As long as the UITextField starts after the colon and does not extend beyond the cell's trailing edge, you should have no issues. Are you laying out using code or Interface Builder?
I have done the similar UI using UITableview. Code to set the Username label for the cell in cellForRowAtIndexPath (use similar code for Password row):
tableViewCell.textLabel.text = #"Username:";
Here is the code to set the text field:
UITextField *textField = [[UITextField alloc] initWithFrame:textFieldRect];
//Insert code for text field delegate and properties e.g. keyboardType, autocorrectionType
tableViewCell.accessoryView = textField;

UILabel can't become first responder and show inputView in UITableView

I tried to create a subclass of UILabel called EditableLabel and implemented canBecomeFirstResponder, isUserInteractionEnabled, both of those two methods return YES, in the meantime, I over-write inputView and inputAccessoryView and make them writable.
My problem is that when I tap on the label, the inputView can't be shown on the screen. Anybody know how to implement the subclass of UILabel view and let the inputView shown?
Thank you very much.
Why not just use a UITextField and set its borderStyle to UITextBorderStyleNone?

Resources