gpt4 book ai didi

ios - 我的 UIButton 的位置在所有模拟器中都不同

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:57:37 25 4
gpt4 key购买 nike

我在一个项目下。因为我使用代码(不是通过 Storyboard)在我的 View Controller 底部创建了一个 uibutton。但是当我运行我的应用程序时,我的 uibutton 被放置在不同的位置。例如在 iphone 5,6模拟器处于某个位置。在 4s 中,ipad 模拟器我的 uibutton 是不可见的。我还检查了我自己的设备(iphone 6),因为我的 uibutton 也看不到。

需要

我使用下面的代码来创建和放置我的按钮位置。但它不适合一个位置。

 CGFloat buttonSize = 40;

UIButton * disButton = [[UIButton alloc] init];
disButton.backgroundColor = [UIColor redColor];
UIImage *btnImage = [UIImage imageNamed:@"23"];
[disButton setImage:btnImage forState:UIControlStateNormal];
disButton.frame = CGRectMake(150, 523, 40, 40);
[overlayView addSubview:disButton];
[disButton addTarget:self action:@selector(dismissPopUpViewController)
forControlEvents:UIControlEventTouchUpInside];

在我的代码中,我用来在这一行中放置位置:

disButton.frame = CGRectMake(150, 523, 40, 40);

=> x-position = 150

=> Y-position = 523

请为这个问题提供一些代码解决方案。

最佳答案

根据关于您问题的所有评论。您需要为您的 UIButon 设置约束。仅使用 centre x,centre y 因为这将有助于查看您的布局所有设备。并且已经有针对您的问题的解决方案。请参阅以下链接以设置 UIButton

的自动布局

Link 1

Link 2

Link 3

当然这对你有帮助!

关于ios - 我的 UIButton 的位置在所有模拟器中都不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32801043/

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