gpt4 book ai didi

iphone - autoresizingMask 和固定边距的问题

转载 作者:行者123 更新时间:2023-12-01 17:02:41 25 4
gpt4 key购买 nike

我试图让它与 ViewController View 中的代码一起工作:

alt text

但我无法让它工作。

我试过了

-(void)loadView {
UIView *contentView = [[[UIView alloc] init] autorelease];
self.view = contentView;
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(5,5,0,100);
button.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[contentView addSubview:button];
}

但是按钮的宽度仍然是 super View 的宽度......

我敢肯定有一个简单的解释。

谢谢大家!

安东尼奥

最佳答案

-initWithFrame:是 UIView 的指定初始化器。在 Mac 端 (NSView) 我知道使用 -init 时会发生奇怪的事情而不是 -initWithFrame: .也许这就是问题所在?

关于iphone - autoresizingMask 和固定边距的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4163948/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com