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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:34:49+00:00 2026-05-26T05:34:49+00:00

i am doing application where i have taken two views Portrait and Landscape. i

  • 0

i am doing application where i have taken two views Portrait and Landscape. i am creating a label programitically and calling it by parameter passing.As i want the position of the label to be changed in the landscapeView so i am taking two views.Instead i want to do in a SingleView

instead of using two views i want to have only one view and set the label position accordingly in portrait and landscape.

so please suggest me how to have only one view and change the textLabel position according to the view..please suggest me with sample code.

At present i am using the below code

[self.portraitView addSubview:[self createLabel:CGRectMake(450,140,60,20):@"Ratings:"]];      
[self.landscapeView addSubview:[self createLabel:CGRectMake(600,140,60,20):@"Ratings:"]];

-(UILabel*)createLabel:(CGRect)frame :(NSString*)labelTitle {
    UILabel *myLabel = [[UILabel alloc] initWithFrame:frame]; 
    [UIFont fontWithName:@"Arial" size:13];  
     myLabel.text = labelTitle;     
}
  • 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-05-26T05:34:50+00:00Added an answer on May 26, 2026 at 5:34 am
    1. Make your UILabel *myLabel a class variable by declaring it in your .h file.
    2. Call the createLabel method in the viewDidLoad method of your viewController based on the correct device orientation.

    -(void) viewDidLoad

    {
           UIDeviceOrientation orientation = [UIDevice currentDevice].orientation
    
    if(orientation == UIDeviceOrientationPortrait)
               CGRect frame = CGRectMake(450,140,60,20);
    else
               CGRect frame = CGRectMake(600,140,60,20);
    
            myLabel = [[UILabel alloc] initWithFrame:frame]; 
            [UIFont fontWithName:@"Arial" size:13];  
             myLabel.text = labelTitle;     
    }
    
    1. Reset the frame in this method

    -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

    {
         if(interfaceOrientation == UIInterfaceOrientationLandScape)
              {      
                  mylabel.frame = CGRectMake(600,140,60,20);  //your landscape frame
                  mylabel.text = @"Ratings:";
              }
        else
           {
              mylabel.frame = CGRectMake(450,140,60,20); // your portrait frame
              mylabel.text = @"Ratings:";
           }
    }
    

    You will need to dig around a little bit for covering all the possible orientations in this method.

    Cheers!!!

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

Sidebar

Related Questions

I have a .net application that is doing COM interop and calling some native
I am doing an application in Yii Framework.I have progressed to some way like
Now I am doing an application.In my app I have to change textview value
Hello i'm doing a application in php, and i have a list of items
I'm doing some performance tuning and capacity planning for a low-latency application and have
I have an application that after it finishes doing it's work schedules itself to
i am doing one small application , wheich have login functionality, in the user
i am doing a web application in flex. i have a list of items
I have problem doing OTA installation for my iPad application. I updated my enterprise
I have a web application where I am doing a Response.Redirect(Register.aspx) page in a

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.