0

I'm making an app and i'm trying to get a button to move to certain coordinates depending on the screen size of the phone (4, 4S, 5, etc). I have correct syntax but the button will not move at all. Here is the part of my .m ViewController file:

- (void)viewDidLoad
{
    if([[UIScreen mainScreen] respondsToSelector:NSSelectorFromString(@"scale")])
    {
        if ([[UIScreen mainScreen] scale] < 1.1) {
            CGRect frame = done.frame;
            frame.origin.x = 129; //New x coordinate
            frame.origin.y = 401; //New y coordinate
            done.frame = frame;
            [done setNeedsDisplay];
            NSLog(@"Standard Resolution");
        }
        if ([[UIScreen mainScreen] scale] > 1.9) {
            NSLog(@"High Defenition Resolution");
        }
    }

    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

The NSLog is triggering in the console saying Standard Resolution, but the button doesn't move from where I placed it in the XIB file. This may be a small stupid mistake but hopefully you can help me anyways.

P.S. Yes, I did link my IBOutlet to the button.

4

1 回答 1

0

If you started this project in iOS 6 / Xcode 4.5, Autolayout will be on by default. See my post on this topic here: UIButton does not move if called after addSubView

于 2012-10-27T02:27:32.543 回答