简体   繁体   English

在XCode中设置Interface Builder对象坐标

[英]Set Interface Builder Object Coordinates in XCode

First question on StackOverflow, so please excuse me if I haven't done all the proper steps, although I've tried searching for an answer for a while now. 关于StackOverflow的第一个问题,请原谅我,如果我没有完成所有正确的步骤,虽然我已经尝试了一段时间寻找答案。

I'm trying to change the coordinates of multiple objects in a UIView from Interface Builder when the iPhone changes from portrait mode to landscape mode. 当iPhone从纵向模式更改为横向模式时,我正在尝试从Interface Builder更改UIView中多个对象的坐标。 I don't want so scale the view, but I want to rearrange the objects in it when the iPhone turns into landscape mode, so that all the objects will fit better. 我不希望如此缩放视图,但是当iPhone变为横向模式时,我想重新排列其中的对象,以便所有对象都更适合。 Currently I'm looking for a way to programmatically set the X,Y coordinates, but if there is a better way to go about doing this, let me know. 目前我正在寻找一种以编程方式设置X,Y坐标的方法,但如果有更好的方法可以做到这一点,请告诉我。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
    /* Move IBOutlets to different X,Y coordinates  */

}   
return YES;

shouldAutorotateToInterfaceOrientation: should only be used the answer the question of whether the view supports a particular orientation. shouldAutorotateToInterfaceOrientation:应该只回答视图是否支持特定方向的问题。 Use willRotateToInterfaceOrientation: or didRotateFromInterfaceOrientation to rearrange objects. 使用willRotateToInterfaceOrientation:didRotateFromInterfaceOrientation重新排列对象。

Actually, it would probably be even better to subclass UIView and override layoutSubviews . 实际上,将UIView子类化并覆盖layoutSubviews可能会更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM