适应屏幕为纵向缺陷的Objective-C

问题描述:

好了,所以我在和当设备进入横向视图的问题的一点点,所以我决定通过代码这个改变我的文本框的位置:适应屏幕为纵向缺陷的Objective-C

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { 
UIInterfaceOrientation orientation = [[UIApplication sharedApplication]statusBarOrientation]; 

NSLog(@"SPIN"); 


if (orientation == UIDeviceOrientationPortrait || orientation == UIDeviceOrientationPortraitUpsideDown) { 

    CGRect frame = [self.a frame]; 
    frame.origin.x = 20; 
    frame.origin.y = 57; 
    [self.a setFrame:frame]; 

    CGRect frame2 = [self.b frame]; 
    frame2.origin.x = 20; 
    frame2.origin.y = 132; 
    [self.b setFrame:frame2]; 

    CGRect frame3 = [self.c frame]; 
    frame3.origin.x = 20; 
    frame3.origin.y = 207; 
    [self.c setFrame:frame3]; 


} else { 

    CGRect frame = [self.a frame]; 
    frame.origin.x = 83; 
    frame.origin.y = 21; 
    [self.a setFrame:frame]; 

    CGRect frame2 = [self.b frame]; 
    frame2.origin.x = 204; 
    frame2.origin.y = 21; 
    [self.b setFrame:frame2]; 

    CGRect frame3 = [self.c frame]; 
    frame3.origin.x = 330; 
    frame3.origin.y = 21; 
    [self.c setFrame:frame3]; 



} 

} 

它的工作就好了,一切都在那里它是suppost到,问题是当点击任何一个文本框的写的东西全部的bug并最终看起来像这样:

呃..那没关系显然我需要至少10个声望才能发布图片,所以下面是对该图片显示的描述:

图像显示3 uisegmented控制和3个文本框挤堆叠在彼此的顶部上在屏幕的最上方

,所以我比较一个业余爱好者比在此亲的,所以我道歉,如果这是一个愚蠢的问题,但我在这里做错了什么?另外还有更好的方法来适应你的观点?

+1

邮政截图链接和2K用户将嵌入它。 – Undo

+0

这听起来像是一个自动布局问题。尝试关闭自动布局,看看是否可以解决问题。 – rdelmar

尝试使用自动布局,或者可能在您使用的不同视图上自动调整大小的遮罩。在uiview中有一个属性叫做autoresizingmask。

您可以检查此以供参考: http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIView_Class/UIView/UIView.html