我在(可能是错误的)假设中,在xib中启用右边距指示符等同于使用UIViewAutoresizingFlexibleLeftMargin内部代码等等.
所以,我曾经根据这个快照思考:

今天晚些时候我不得不交叉检查,偶然发现了这个帖子.
还有苹果文档,标题为标题部分 - "使用自动调整规则自动处理布局更改"链接:https://developer.apple.com/library/content/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/CreatingViews/ CreatingViews.html
所以我现在脑子里有一个更新的概念,关于如何以编程方式设置自动调整掩码等同于xib设置:
场景1:仅设置(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)相当于:

在XIB?
场景2:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin)代码设置相当于:

在XIB?
我的2个更新方案是否正确?我现在理解了吗?
我所经历和删除每一个用户约束但我仍然收到以下错误ONLY后,我旋转设备.我完全不知道为什么.有没有人有任何想法?
2013-01-14 21:30:31.363 myApp[35869:c07] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x84543d0 h=--& v=--& V:[UIView:0xa330270(768)]>", …Run Code Online (Sandbox Code Playgroud) 我已经使用Interface Builder列出了一些子视图,但我想在代码中进行.
我已经阅读了有关设置view.autoresizingMask属性的 UIView文档.我正在寻找一个合理的解释,如何通过使用提供的各种掩码(例如UIViewAutoresizingFlexibleLeftMargin,等)来翻译支柱和弹簧.
我必须以编程方式设置autoresizingMask UIView.
我不知道如何实现这一点.
我UITextView想要填充它superView,这是UIView一个UIViewController实例内的平原.
看来,我不能让UITextView这样做完全由使用的API指定的性质autoresizingMask和autoresizesSubviews.如此处所示设置这些没有任何作用; 在UITextView依然很小,即使它superView充满屏幕.
// use existing instantiated view inside view controller;
// ensure autosizing enabled
self.view.autoresizesSubviews = YES;
self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight|
UIViewAutoresizingFlexibleWidth;
// create textview
textView = [[[UITextView alloc] autorelease] initWithFrame:CGRectMake(0, 0, 1, 1)];
// enable textview autoresizing
[textView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|
UIViewAutoresizingFlexibleHeight];
// add textview to view
[self.view addSubview:textView];
Run Code Online (Sandbox Code Playgroud)
但是,如果我在视图控制器中实例化我自己的视图,替换它的'.view'属性,那么一切都按预期工作,并且textView填充其超级视图:
// reinstantiate view inside view controller
self.view = [[UIView alloc]init];
// create textview …Run Code Online (Sandbox Code Playgroud) 我正在使用UINavigationBar的自定义标题视图,其代码如下:
// Set a label to the nav bar
THLabel *titleLabel = [[THLabel alloc] init];
titleLabel.text = @"Test";
titleLabel.font = [UIFont fontWithName:APP_FONT size:22.0];
titleLabel.frame = CGRectMake(0, 0, 100, 30);
titleLabel.textAlignment = NSTextAlignmentCenter;
titleLabel.textColor = CUSTOM_LIGHT_BLUE;
titleLabel.strokeColor = kStrokeColor;
titleLabel.strokeSize = kStrokeSize;
self.navigationItem.titleView = titleLabel;
Run Code Online (Sandbox Code Playgroud)
问题是,当呈现一个新的viewcontroller然后返回到原始视图控制器时,这个自定义视图会移动,然后重新居中.请参阅视频以了解相关信息.
请在此处观看视频:https: //www.youtube.com/watch?v = 961CCVQmpJM&feature = youroutu.be
我已经使用故事板和每个视图控制器的代码禁用了导航控制器的每个子视图的自动调整:
// Set the navigation bar hidded on the log in view
UINavigationController* mainViewController = (UINavigationController*)self.appDelegate.window.rootViewController;
[mainViewController setNavigationBarHidden:YES];
[[mainViewController navigationBar] setAutoresizesSubviews:NO];
Run Code Online (Sandbox Code Playgroud)
但它仍然调整大小!我怎么能阻止这个 - 我做错了什么?谢谢!
我已经启用了自动布局在iOS视图,并有UIToolbar一个UISearchBar与UISegmentControl载带的工具栏.我想要UISearchBar有一个灵活的宽度,所以我需要添加一个约束来强制这个,但从我可以告诉你不能添加约束到UIToolbar接口生成器中的项目.所有选项均已禁用.
在AutoLayout我完成这个之前autoresizingmasks.
是否允许约束UIToolbars/UINavigationBars?
使用autolayout时如何才能实现这一目标?
阅读后UIView的autoresizingMask对SO和developer.apple.com我还是不清楚的目的是什么.设置此属性的必要条件是什么?
我应该如何在NSSplitView子视图中使用自动布局约束?
我的NSSplitView子视图有3子视图:topPane,tableContainer和bottomPane我这样设置约束:
NSDictionary* views = NSDictionaryOfVariableBindings(topPane, tableContainer, bottomPane);
for (NSView* view in [views allValues]) {
[view setTranslatesAutoresizingMaskIntoConstraints:NO];
}
[myView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[topPane(34)][tableContainer][bottomPane(24)]|"
options:0
metrics:nil
views:views]];
[mySplitView addSubview:myView];
Run Code Online (Sandbox Code Playgroud)
在控制台中得到这个:
Unable to simultaneously satisfy constraints:
(
"<NSLayoutConstraint:0x7fd6c4b1f770 V:[NSScrollView:0x7fd6c4b234c0]-(0)-[CPane:0x7fd6c4b2fd10]>",
"<NSLayoutConstraint:0x7fd6c4b30910 V:[CPane:0x7fd6c4b2f870(34)]>",
"<NSLayoutConstraint:0x7fd6c4b30770 V:|-(0)-[CPane:0x7fd6c4b2f870] (Names: '|':NSView:0x7fd6c4b22e50 )>",
"<NSLayoutConstraint:0x7fd6c4b212f0 V:[CPane:0x7fd6c4b2fd10]-(0)-| (Names: '|':NSView:0x7fd6c4b22e50 )>",
"<NSLayoutConstraint:0x7fd6c4b2f910 V:[CPane:0x7fd6c4b2f870]-(0)-[NSScrollView:0x7fd6c4b234c0]>",
"<NSLayoutConstraint:0x7fd6c4b21290 V:[CPane:0x7fd6c4b2fd10(24)]>",
"<NSAutoresizingMaskLayoutConstraint:0x7fd6c3630430 h=--& v=--& V:[NSView:0x7fd6c4b22e50(0)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fd6c4b1f770 V:[NSScrollView:0x7fd6c4b234c0]-(0)-[CPane:0x7fd6c4b2fd10]>
Run Code Online (Sandbox Code Playgroud)
我认为<NSAutoresizingMaskLayoutConstraint:0x7fd6c3630430 h=--& v=--& V:[NSView:0x7fd6c4b22e50(0)]> …
我在UITableview中使用xcode 6中的自动调整大小但它无法正常工作.我想使用autoresizing.I在故事板的UITableviewController类中的静态单元格中添加了textfield.屏幕外的文本字段无论是横向还是纵向.我不想使用autolayout我的整个项目是自动化. 
autoresizingmask ×10
ios ×8
uiview ×5
objective-c ×3
autolayout ×2
iphone ×2
autoresize ×1
cocoa ×1
cocoa-touch ×1
ios7 ×1
ipad ×1
nssplitview ×1
storyboard ×1
swift ×1
uitableview ×1
uitoolbar ×1
xcode ×1
xcode6 ×1