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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:44:58+00:00 2026-05-18T01:44:58+00:00

I try to change the read and change the position from a UILabel. This

  • 0

I try to change the read and change the position from a UILabel. This UILabel has been created in Interface Builder and now i want to read and change the position inside another class, when i call a method in the MainVieController class.

But how can i do that, i’ve read several forums but i can’t get it work. Here’s also some sample code. I hope someone can help me with this.

MainViewController.h

#import <UIKit/UIKit.h>
@class NewClass;

@interface MainViewController : UIViewController {

    UILabel *daLabel;

}

@property (nonatomic, retain) IBOutlet UILabel *daLabel;

@end

MainViewController.m

#import "MainViewController.h"
#import "NewClass.h"

@implementation MainViewController
@synthesize daLabel;

- (void)viewDidLoad {

    [super viewDidLoad];

    NewClass *anotherClass = [[NewClass alloc] init];
    [anotherClass test];

}

@end

NewClass.h

#import <Foundation/Foundation.h>
@class MainViewController;

@interface NewClass : NSObject {

}

@end

NewClass.m

#import "NewClass.h"
#import "MainViewController.h"

@implementation NewClass

- (void)test {

    MainViewController *MainController = [[MainViewController alloc] init];

    CGRect labelPosition = MainController.daLabel.frame;
    NSLog(@"POSITION: %f", labelPosition.origin.x); // Returns 0.000000

}

@end
  • 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-18T01:44:59+00:00Added an answer on May 18, 2026 at 1:44 am

    I’m not sure why you’re creating another instance of your view controller in NewClass, which is loaded by your view controller. Maybe just pass “self” in the call to the test method? But if you want to change the position of your UILabel, just change labelPosition and then set daLabel.frame to the modified labelPosition. For example:

    - (void)viewDidLoad {
        [super viewDidLoad];
        NewClass *anotherClass = [[NewClass alloc] init];
        [anotherClass test:self];
    
    }
    
    - (void)test:(MainViewController *)mvc {
        CGRect labelPosition = mvc.daLabel.frame;
        NSLog(@"POSITION: %f", labelPosition.origin.x); // Returns 0.000000
        labelPosition.origin.x = 50;
        mvc.daLabel.frame = labelPosition;  // Now moved to 50.000000
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been having this problem for a while now. I created a brand new
I've been wanting to work on this application for about a year now. I
I have developed a service with vb.net. This service is been installed from a
In Delphi 2007, in a mouse move event, I try to change the mouse
Try loading this normal .jpg file in Internet Explorer 6.0. I get an error
We try to convert from string to Byte[] using the following Java code: String
I have a revision.txt file in my SVN project. Basically I want that this
I wrote simple test add 100 items to [Collection] read 1000000 times from [Collection]
I currently am part of a project where there is an interface like this:
I want to read an input string and return it as a UTF8 encoded

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.