Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8116003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:40:18+00:00 2026-06-06T03:40:18+00:00

So I created a custom text view using core graphics and have it conformed

  • 0

So I created a custom text view using core graphics and have it conformed to the UITextInput and UITextInputTraits protocols. Everything works fine except for one weird/annoying behavior. The keyboard correctly displays auto correct suggestions, but when the use taps on a suggestion labelled with an ‘X’, it doesn’t dismiss the suggestion but instead inserts the suggestion. I’ve checked, and in all other programs tapping on the a suggestion with an ‘X’ dismisses the suggestion. How do I fix this?

In my custom text view I have the following iVars:

//UITextInputTraits
UITextAutocapitalizationType _uiAutoCap;
UITextAutocorrectionType _uiAutoCorrect;
UITextSpellCheckingType _uiSpellCheck;
UIKeyboardType _uiKeyboard;
UIKeyboardAppearance _uiKeyboardAppearance;
UIReturnKeyType _uiReturnType;
BOOL _uiEnableAutoReturn;
BOOL _uiSecureText;

Which are synthesized to the appropriate TextInputTraits properties:

@synthesize autocapitalizationType=_uiAutoCap, autocorrectionType=_uiAutoCorrect, spellCheckingType=_uiSpellCheck, keyboardType=_uiKeyboard, keyboardAppearance=_uiKeyboardAppearance, returnKeyType=_uiReturnType, inputDelegate=_uiTextDelegate, enablesReturnKeyAutomatically=_uiEnableAutoReturn, secureTextEntry=_uiSecureText;

And they’re initialized with the following default values:

    _uiAutoCorrect = UITextAutocorrectionTypeDefault;
    _uiSpellCheck = UITextSpellCheckingTypeDefault;
    _uiKeyboardAppearance = UIKeyboardAppearanceDefault;
    _uiAutoCap = UITextAutocapitalizationTypeNone;
    _uiReturnType = UIReturnKeyDefault;
    _uiEnableAutoReturn = NO;
    _uiSecureText = NO;
    _uiKeyboard = UIKeyboardTypeDefault;

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T03:40:19+00:00Added an answer on June 6, 2026 at 3:40 am

    Edit: Possible answer

    When you tap to close the suggestion, your tap is likely intercepted by your view first which presumably changes the selected range of the text (which causes UITextInput to accept the suggestion). Not the best solution, but UITextInput calls

    - (NSDictionary *)textStylingAtPosition:(UITextPosition *)position inDirection:(UITextStorageDirection)direction;
    

    when it wants to make a suggestion, so, you could have an ivar (BOOL) that stores whether or not there is a suggestion (make its value NO whenever a UIKeyInput method is called and YES when the textStyling method is called). Then, modify your gesture recognizer so that it will not change the selection if the aforementioned ivar is YES and the tap is in the rect of the suggestion box (You could get this rect by doubling the height of the rect returned from – (CGRect)firstRectForRange:(UITextRange *)range;). Hope that works.

    Edit: you should just be able to implement the UIGestureRecognizerDelegate method:

    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch;
    

    So that it only receives a touch if touch.view == (yourTextView)

    I am having the same issue, and don’t yet have a solution; however, I do believe that you should conform to UITextInputTraits by creating functions that return the value you would like for the property. Example: for the trait UITextAutoCorrectionType to have a value of UITextAutocorrectionTypeDefault, you should provide an accessor method:

    - (UITextAutocorrectionType)autocorrectionType {
        return UITextAutocorrectionTypeDefault;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have created custom listview by using the Base adapter. List view contains Text
friends, i have created custom title bar using following titlebar.xml file with code <?xml
I have created a custom tree view control in .NET to display directories. What
I have created a custom AlertDialog with multiple EditText fields using a custom layout.
I have created custom component for displaying text with either Simple or Password mode,
I have a telerik mvc grid in a Razor view. I am using custom
I have created a custom view by extending AutoCompleteTextView (with a specialized function called
I am new to iphone development, i have created sms application using Text Links(sms:)
I have created a custom View (let's call it MyView ) which basically just
I am using asp.NET 4.0 with C# and have recently created a custom design

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.