When I use CGRectMake in my program, it behaves very strangely. In Interface Builder, my button has coordinates of (260, 388)
and is always in portrait mode. When I put in the following code (just to experiment), which should keep it in the same place, the X value is fine but the Y value puts it in a spot more like 300.
self.theButton.frame = CGRectMake(260, 388, 120, 120);
Are there some quirks in CGRectMake that cause the coordinates to get screwy? No other lines of code affect the size or shape of this button and when I comment out this line the button is in the correct place from IB.
EDIT: Autolayout is not on. EDIT: The problem seems to be that my code's concept of the frame's Y value and IB's concept don't match up.
Buttons 1.1 through 3.2 are listed here in their order from top to bottom. The first number after the button number is their (correct) Y value according to IB. The second number is their Y value according to an NSLog's button.frame.origin.y. The last number is the difference. The difference grows exponentially, by 50 or 51 each time. This is clearly the problem, I'm setting my CGRectMake using IB's y value system but the code is using some other numbers for the Y value. Any ideas as to why?
Button -> IB Y-value -> NSLog Y-Value -> Difference
1.1 -> 4 -> 5 -> 1
1.2 -> 132 -> 184 -> 52
1.3 -> 260 -> 362 -> 102
3.1 -> 388 -> 541 -> 153
3.2 -> 516 -> 719 -> 203
EDIT: My size inspector:
The first image here is part of my IB (correct). The second image is when I run the program, you see the one Item button overlaps the magnifying glass (ignore the low alpha).
EDIT: After further experimenting, it appears that using CGRect to move UIViews works totally fine EXCEPT when using it in viewDidLoad. I moved the code to viewDidAppear and it now works. No idea why this happens but there it is. Closing this question out.