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 8061999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:31:11+00:00 2026-06-05T10:31:11+00:00

I want to have an Edit barButtonItem, when pressed I want to be able

  • 0

I want to have an Edit barButtonItem, when pressed I want to be able to select a segmented control and edit the segment title I select and save it. Is this possible?

  • 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-05T10:31:13+00:00Added an answer on June 5, 2026 at 10:31 am

    Took me some time to come up with the example, but here it is!!!

    Here is what is in my UIViewController header file:

    @interface optionsViewController : UIViewController <UIPopoverControllerDelegate, UITextFieldDelegate> {
        IBOutlet UISegmentedControl *       centerAreaSizeSelector;
    
        // Added to support this example
        UISegmentedControl * controlBeingEdited;
        unsigned int segmentBeingEdited;
    }
    
    -(IBAction)centerAreaSizeSelector:(id)sender;
    @end
    

    Obviously my UISegmented control and its action item were connect in Interface Builder.

    You must implement the action item for your segmented control here is mine

    -(IBAction)centerAreaSizeSelector:(id)sender{
        // These are zero Based Reads from the selectors
        unsigned char centerAreaSizeSelection = centerAreaSizeSelector.selectedSegmentIndex;
    
        // Here we instantiate a NEW invisible UITextField to bring up the keyboard.
        UITextField * textField = [[UITextField alloc] init];
        [self.view addSubview:textField];
        textField.hidden = YES;
        textField.keyboardType = UIKeyboardTypeDefault;
        textField.returnKeyType = UIReturnKeyDone;
        textField.text = [centerAreaSizeSelector titleForSegmentAtIndex:centerAreaSizeSelection];
        textField.delegate = self;
        [textField becomeFirstResponder];
    
        // The below variable are defined globally to allow the keyboard delegate routines
        // to know which segmented control and which item within the control to edit
        // My design has multiple UISegmentedControls so this is needed for separation
        controlBeingEdited = centerAreaSizeSelector;  // of type UISegmentedControl
        segmentBeingEdited = centerAreaSizeSelection; // of type unsigned int
    }
    

    Implement the following 3 UITextFieldDelegate Methods as follows

    // Implement the keyboard delegate routines
    -(BOOL)textFieldShouldReturn:(UITextField *)textField{
        [textField resignFirstResponder];
        [textField release];
        controlBeingEdited = nil;
        segmentBeingEdited = 0;
        return YES;
    }
    
    -(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
        NSString * theString = [textField.text stringByReplacingCharactersInRange:range withString:string];
    
        [controlBeingEdited setTitle:theString forSegmentAtIndex:segmentBeingEdited];
    
        return YES;
    }
    
    -(void)textFieldDidEndEditing:(UITextField *)textField{
        [controlBeingEdited setTitle:textField.text forSegmentAtIndex:segmentBeingEdited];
    }
    

    This implements a key-by-key visible editing of a UISegmentedControl element.

    NOTES:
    This does not in any way implement the auto-resizing that may be necessary if the text is larger than the space provided by the control.

    This also does not implement any form of visible cursor or visible selection code.

    This will leave the textfield caret position after the last character in the string. It will copy the current UISegmentedControl’ text into the invisible textfield prior to editing so that you don’t lose your copy, although it could easily be edited to clear both prior to editing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this html code that i want to edit with jQuery. Here is
I have a UITableView that I want to edit inside of a UITableViewController. This
I want have this ability to select multiple items with checkboxes and delete them
I won't want to have edit any working sets. I just want a way
I have 3 (Edit) mutually exclusive IEnumerables that I want to iterate over. I
I have a edit in place section to which I want to add a
I have an input edit field where the user can enter data. I want
I have a text file that I want to edit using Java. It has
I have a MFMailComposeViewController wherein I want to edit the mail body, but I
I have some labels that I want to allow users to edit. Is it

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.