【问题标题】:Adjust UIView position for iPhoneX / iPad / iPhone6 within a statement在语句中调整 iPhoneX / iPad / iPhone6 的 UIView 位置
【发布时间】:2020-04-02 11:42:46
【问题描述】:

更新了一些旧代码并修复了所有问题,除了 UIView 中的一个讨厌的按钮,该按钮仅在某些设备上未显示在正确的位置。

它适用于所有 iPad 设备并完美定位,适用于 iPhoneX / XS 和 XR

但是对于 iPhone 5、5s、6、6s、7、8,按钮没有显示在正确的位置。

我知道这是一个“肮脏”的修复,但实际上是这个按钮导致了问题,其余代码本身运行良好,所以我不想重新发明轮子。

这个图片位置本身就是这样设置的;

 #define IDIOM    UI_USER_INTERFACE_IDIOM()
#define IPAD     UIUserInterfaceIdiomPad

if ( IDIOM == IPAD ) {
     [nail5View setFrame:CGRectMake(638, 682, nail5View.frame.size.width, nail5View.frame.size.height)]; // was 358,582
} else {
[nail5View setFrame:CGRectMake(358, 582, nail5View.frame.size.width, nail5View.frame.size.height)];
}

nail5View.autoresizingMask = UIViewAutoresizingNone;
transform = CGAffineTransformMakeRotation(+0.9);
nail5View.transform = transform;

有没有一种方法可以专门针对低于 X 的 iPhone 为它们添加额外的位置?

【问题讨论】:

    标签: ios objective-c xcode


    【解决方案1】:

    您可以检查设备是 iphone 8plus 或更低型号,如 thise

    #define iPhone8AndLesser ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height <= 736)
    

    如果你想要 iphone 8 和 lesse 使用 667 insted of 736 您可以使用

    进行检查
    if ( IDIOM == IPAD ) {
         [nail5View setFrame:CGRectMake(638, 682, nail5View.frame.size.width, nail5View.frame.size.height)]; // was 358,582
    } else {
    if iPhone8AndLesser{
        //Your conditions here;
    }else{
      [nail5View setFrame:CGRectMake(358, 582, nail5View.frame.size.width, nail5View.frame.size.height)];
    }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-30
      • 2021-04-11
      • 1970-01-01
      • 2021-01-16
      • 1970-01-01
      相关资源
      最近更新 更多