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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:06:54+00:00 2026-06-09T19:06:54+00:00

I’ve got the following code which is a segmentedControl for a language selection option.

  • 0

I’ve got the following code which is a segmentedControl for a language selection option. Case 0 is for English and case 1 is for Greek which is then passed to a UITextView. The problem is that every time I press the button for case 1 or 0 I have to go back to the previous view controller which is a table view controller and come back to the “detailViewController” for the correct language to be displayed. Is there a way for this to be done without switching back and forth between the view controllers? Something like a small animation or a refresh or a reload method for UITextView.

 int a;

- (IBAction)languageSeg:(id)sender {

switch (((UISegmentedControl *)sender).selectedSegmentIndex) {

 case 0:

 a=0;

        break;

    case 1:
        a=1;

        break;

    default:

        break;
}
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
}
return self;
}


-(void) viewWillAppear:(BOOL)animated{

[super viewWillAppear:YES];


UIImage *saladImage = [UIImage imageNamed:@"salad.jpg"];

UIImage *fishImage = [UIImage imageNamed:@"fish.jpg"];

 [textDetail setScrollEnabled:YES];

 [textDetail setContentSize:CGSizeMake(320, 190)];


//Switch the UIImages and UILabel based on item



switch (itemNumber) {
    case 0:
        itemName.text = @"Salad";
        itemPic.image = saladImage;
        self.title = @"Salads";

        if (a==0){

            textDetail.text = @"description in english";

        }

        if (a==1){

            textDetail.text = @"description in greek";
        }

        break;


      case 1:

       // etc.
  • 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-09T19:06:55+00:00Added an answer on June 9, 2026 at 7:06 pm

    You can update the text for the textView in the languageSeg: method the same way you set it initially in viewWillAppear:

    I would create a separate method that handles the language switch, then call that method from both viewWillAppear and languageSeg and anywhere else you need it.

    For example, your language setter method would include the code currently at the bottom of viewWillAppear:

    - (void) languageSetter {
    
        switch (itemNumber) {
           case 0:
                itemName.text = @"Salad";
                itemPic.image = saladImage;
                self.title = @"Salads";
    
                if (a==0){
                    textDetail.text = @"description in english";
                }
                if (a==1){
                   textDetail.text = @"description in greek";
                }
          break;
    
          case 1:
            // etc.
          break;
    
          default:
          // default case
          break;
        }
    }
    

    Then your viewWillAppear: method would look like this:

    -(void) viewWillAppear:(BOOL)animated{
    
         [super viewWillAppear:YES];
         UIImage *saladImage = [UIImage imageNamed:@"salad.jpg"];
         UIImage *fishImage = [UIImage imageNamed:@"fish.jpg"];
    
         [textDetail setScrollEnabled:YES];
         [textDetail setContentSize:CGSizeMake(320, 190)];
    
         [self languageSetter];
    }
    

    And your languageSeg: method would look like this:

    - (IBAction)languageSeg:(id)sender {
    
        switch (((UISegmentedControl *)sender).selectedSegmentIndex) {
    
           case 0:
               a=0;
               break;
    
           case 1:
               a=1;
               break;
    
           default:
               break;
        }
    
        [self languageSetter];
    }
    

    A lot of implementation would be dependent on how the rest of your code is set up and your individual needs, but this is the general idea.

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

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.