gsdios / SDAutoLayout

One line of code to implement automatic layout. 一行代码搞定自动布局!支持Cell和Tableview高度自适应,Label和ScrollView内容自适应,致力于做最简单易用的AutoLayout库。The most easy way for autoLayout. Based on runtime.
MIT License
5.9k stars 1.28k forks source link

UITextField 输入文字 退到主屏幕再进来 位置会下垂 或 不见 #214

Closed guifw001 closed 7 years ago

guifw001 commented 7 years ago

UITextField 用SDAutolayout布局 会出现标题的bug,设置Frame不会出现这个问题. 这个如何解决?

IOS 8.2 SDAutolayout 2.1.8 Xcdoe 8.3.3

ShouBinCheng commented 7 years ago

是因为UINavigationController下的UIViewController的self.view的第一个UIScrollView会被偏移。可以这么设置

- (void)viewDidLoad {
    [super viewDidLoad];
    //view置顶
    self.edgesForExtendedLayout = UIRectEdgeAll;
    self.extendedLayoutIncludesOpaqueBars = YES;

    //解决首个scrollView引发的偏移
    self.automaticallyAdjustsScrollViewInsets = NO;
    [self.view addSubview:[UIScrollView new]];

    self.view.backgroundColor = [UIColor whiteColor];
}
guifw001 commented 7 years ago

@iCoobin 谢谢你的答案, 是这原因引起的,昨天发现原因之后 就把这个问题给关了!