草庐IT

TranslatesAutoresizingMaskIntoCon

全部标签

ios - 无法设置 translatesAutoresizingMaskIntoConstraints

在尝试解决与以编程方式将subview添加到ScrollView相关的自动布局问题时,我遇到了many整个互联网上的引用,在各种情况下说要设置translatesAutoresizingMaskIntoConstraints=YES或translatesAutoresizingMaskIntoConstraints=NO,具体取决于具体情况。但是,在Swift中,当我输入时:varview=UIView()view.translatesAutoresizingMaskIntoConstraints=false我收到内联错误:无法分配给“view”中的“translatesAutores

ios - 什么时候应该将 translatesAutoresizingMaskIntoConstraints 设置为 true?

我读过documentation.但是我仍然不确定什么时候不需要将它设置为false。在下面的代码中,如果我将它设置为false,我将根本看不到header。如果我将其保留为true,那么一切都很好。Viewdebughierarchy中的以下内容会给出警告“widthandpositionareambiguous”。functableView(_tableView:UITableView,viewForHeaderInSectionsection:Int)->UIView?{letheader=UIView()header.translatesAutoresizingMaskInto
12