标签: autoresizingmask

以编程方式对Interface Builder/xib/nib自动调整掩码

我在(可能是错误的)假设中,在xib中启用右边距指示符等同于使用UIViewAutoresizingFlexibleLeftMargin内部代码等等.

所以,我曾经根据这个快照思考: 在此输入图像描述

今天晚些时候我不得不交叉检查,偶然发现了这个帖子.

还有苹果文档,标题为标题部分 - "使用自动调整规则自动处理布局更改"链接:https://developer.apple.com/library/content/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/CreatingViews/ CreatingViews.html

所以我现在脑子里有一个更新的概念,关于如何以编程方式设置自动调整掩码等同于xib设置:

场景1:仅设置(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)相当于:

(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)

在XIB?

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

(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin)

在XIB?

我的2个更新方案是否正确?我现在理解了吗?

cocoa-touch uiview ios autoresizingmask

217
推荐指数
2
解决办法
7万
查看次数

无法同时满足约束 - 没有约束

我所经历和删除每一个用户约束但我仍然收到以下错误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)

ipad ios autoresizingmask nslayoutconstraint

57
推荐指数
5
解决办法
8万
查看次数

UIView autoresizingMask - Interface Builder to Code - 以编程方式创建struts和spring - Swift或Objective-C

我已经使用Interface Builder列出了一些子视图,但我想在代码中进行.

我已经阅读了有关设置view.autoresizingMask属性的 UIView文档.我正在寻找一个合理的解释,如何通过使用提供的各种掩码(例如UIViewAutoresizingFlexibleLeftMargin,等)来翻译支柱和弹簧.

objective-c uiview ios autoresizingmask swift

56
推荐指数
2
解决办法
4万
查看次数

以编程方式设置UIView的自动调整掩码?

我必须以编程方式设置autoresizingMask UIView.

我不知道如何实现这一点.

在此输入图像描述

iphone objective-c uiview ios autoresizingmask

54
推荐指数
4
解决办法
5万
查看次数

xcode/iOS:自动调整以填充视图 - 显式帧大小是必不可少的?

UITextView想要填充它superView,这是UIView一个UIViewController实例内的平原.

看来,我不能让UITextView这样做完全由使用的API指定的性质autoresizingMaskautoresizesSubviews.如此处所示设置这些没有任何作用; 在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)

xcode uiview autoresize ios autoresizingmask

36
推荐指数
1
解决办法
8万
查看次数

iOS 7自定义UINavigationBar TitleView在推送或弹出新的View Controller时移动

我正在使用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)

但它仍然调整大小!我怎么能阻止这个 - 我做错了什么?谢谢!

iphone objective-c uinavigationbar ios autoresizingmask

24
推荐指数
2
解决办法
2万
查看次数

iOS Autolayout和UIToolbar/UIBarButtonItems

我已经启用了自动布局在iOS视图,并有UIToolbar一个UISearchBarUISegmentControl载带的工具栏.我想要UISearchBar有一个灵活的宽度,所以我需要添加一个约束来强制这个,但从我可以告诉你不能添加约束到UIToolbar接口生成器中的项目.所有选项均已禁用.

AutoLayout我完成这个之前autoresizingmasks.

是否允许约束UIToolbars/UINavigationBars

使用autolayout时如何才能实现这一目标?

uitoolbar uibarbuttonitem ios autoresizingmask autolayout

23
推荐指数
3
解决办法
2万
查看次数

UIView的autoresizingMask的目的是什么?

阅读后UIViewautoresizingMask对SO和developer.apple.com我还是不清楚的目的是什么.设置此属性的必要条件是什么?

uiview ios autoresizingmask

22
推荐指数
2
解决办法
2万
查看次数

NSSplitView和autolayout

我应该如何在NSSplitView子视图中使用自动布局约束?

我的NSSplitView子视图有3子视图:topPane,tableContainerbottomPane我这样设置约束:

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)]> …

cocoa nssplitview autoresizingmask autolayout

22
推荐指数
2
解决办法
1万
查看次数

在Xcode 6中的UITableView中自动调整大小问题

我在UITableview中使用xcode 6中的自动调整大小但它无法正常工作.我想使用autoresizing.I在故事板的UITableviewController类中的静态单元格中添加了textfield.屏幕外的文本字段无论是横向还是纵向.我不想使用autolayout我的整个项目是自动化. 文本域

演示项目

storyboard uitableview autoresizingmask ios7 xcode6

22
推荐指数
2
解决办法
7552
查看次数