我不知道这个:
是否有可能当用户切换到横向视图然后uitextfied的大小发生变化,因为我在视图中有4个文本文件....只是外观
答案 0 :(得分:2)
如果你正在使用IB,你有两种方法可以做到。
使用Interface Builder的对象检查器中的自动调整大小属性。这将自动调整文本字段的大小。
如果这不能满足您的需求,您必须在ViewController方法中控制它
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
if (UIInterfaceOrientationIsPortrait (fromInterfaceOrientation)) {
txtField.frame = CGRectMake(0, 0, 400, 31);
}
else {
//orientation for portrait
}
}
答案 1 :(得分:0)
是的,你可以通过使用“frame”属性来改变uitextfied的大小
txtField.frame = CGRectMake(0, 0, 400, 31);
根据设备方向的条件改变尺寸