iOS15适配问题:viewForSupplementaryElementOfKind表头和表尾复用闪退,UITableView section header多22像素等问题

简介: iOS15适配问题:viewForSupplementaryElementOfKind表头和表尾复用闪退,UITableView section header多22像素等问题

1.广告权限提示,需要在viewDidLoad调用授权,不然弹不出来。

Guideline 2.1 - Information Needed


We’re looking forward to completing our review, but we need more information to continue. Your app uses the AppTrackingTransparency framework, but we are unable to locate the App Tracking Transparency permission request when reviewed on iOS 15.0.1.


Since you indicated in App Store Connect that you collect data in order to track the user, we need to confirm that App Tracking Transparency has been correctly implemented.


Next Steps

Please explain where we can find the App Tracking Transparency permission request in your app. The request should appear before any data is collected that could be used to track the user.


If your app does not track users, please update your app privacy information in App Store Connect. You must have the Account Holder or Admin role to update app privacy information.


If you’ve implemented App Tracking Transparency but the permission request is not appearing on devices running the latest OS, please review the available documentation and confirm App Tracking Transparency has been correctly implemented.


Resources

Tracking is linking data collected from your app with third-party data for advertising purposes, or sharing the collected data with a data broker. Learn more about tracking.

See Frequently Asked Questions about the new requirements for apps that track users.

Review developer documentation for App Tracking Transparency.

if (@available(iOS 15, *)) {

[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {

}];

}

这个新加的 到viewDidLoad里面去调用

2.后台持续定位就是不使用定位时第一安装也弹出定位授权提示框。

指南 2.5.4 - 性能 - 软件要求

您的应用在 Info.plist 文件的 UIBackgroundModes 键中声明支持位置,但没有任何需要持久位置的功能。在 Info.plist 文件的 UIBackgroundModes 键中声明支持位置的应用程序必须具有需要持久位置的功能。


后续步骤

要解决此问题,请修改您的应用以包含需要在应用处于后台时持续使用实时位置更新的功能。

如果您的应用不需要持续实时位置更新,请从 UIBackgroundModes 键中删除“位置”设置。如果您的应用功能不需要持续实时位置更新,您可能希望使用显着变化位置服务或区域监控位置服务。


资源

有关更多信息,请查看启动显着变化位置服务和监控地理区域。

解决方案:去除持续定位配置只保留使用期间定位或增加后台持续定位的页面。

3.UICollectionReusableView不注册UICollectionElementKindSectionFooter,foot复用UICollectionElementKindSectionHeader闪退。

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0 && [kind isEqualToString:UICollectionElementKindSectionHeader])
    {
        if (self.collectionHeadView)
        {
            return self.collectionHeadView;
        }

        UICollectionReusableView *headView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader
                                                                                withReuseIdentifier:@"collectionHeadView" forIndexPath:indexPath];
        self.collectionHeadView = headView;
//        UIView *footViewPanel = [[UIView alloc] initWithFrame:CGRectMake(0, 0, FULL_WIDTH, 105)];
//        footViewPanel.backgroundColor = [UIColor clearColor];
        [headView addSubview:self.selectTypeHeadView];
        return headView;
    }
    else
    {
        if (self.lineFootView)
        {
            return self.lineFootView;
        }

        UICollectionReusableView *lineFootView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader
                                                                                withReuseIdentifier:@"lineFootView" forIndexPath:indexPath];
        self.lineFootView = lineFootView;
        UIView *lineFootViewPanel = [[UIView alloc] initWithFrame:CGRectMake(0, 0, FULL_WIDTH, BG_1PX)];
        lineFootViewPanel.backgroundColor = [UIColor clearColor];
        [lineFootView addSubview:lineFootViewPanel];
        return lineFootView;
    }
}

解决方案注册UICollectionElementKindSectionFooter,使用正确的UICollectionElementKindSectionFooter。

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0 && [kind isEqualToString:UICollectionElementKindSectionHeader])
    {
        if (self.collectionHeadView)
        {
            return self.collectionHeadView;
        }

        UICollectionReusableView *headView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader
                                                                                withReuseIdentifier:@"collectionHeadView" forIndexPath:indexPath];
        self.collectionHeadView = headView;
//        UIView *footViewPanel = [[UIView alloc] initWithFrame:CGRectMake(0, 0, FULL_WIDTH, 105)];
//        footViewPanel.backgroundColor = [UIColor clearColor];
        [headView addSubview:self.selectTypeHeadView];
        return headView;
    }
    else
    {
        if (self.lineFootView)
        {
            return self.lineFootView;
        }

        UICollectionReusableView *lineFootView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter
                                                                                withReuseIdentifier:@"lineFootView" forIndexPath:indexPath];
        self.lineFootView = lineFootView;
        UIView *lineFootViewPanel = [[UIView alloc] initWithFrame:CGRectMake(0, 0, FULL_WIDTH, BG_1PX)];
        lineFootViewPanel.backgroundColor = [UIColor clearColor];
        [lineFootView addSubview:lineFootViewPanel];
        return lineFootView;
    }
}
[_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"lineFootView"];

闪退日志:

2021-11-11 13:40:13.711962+0800 光予露家长端[55011:3110902] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'the view returned from -collectionView:viewForSupplementaryElementOfKind:atIndexPath: does not match the element kind it is being used for. When asked for a view of element kind 'UICollectionElementKindSectionFooter' the data source dequeued a view registered for the element kind 'UICollectionElementKindSectionHeader'.'
*** First throw call stack:
(0x181d5b05c 0x19a275f54 0x18361c99c 0x184326c6c 0x184393844 0x1842e73c4 0x1842f9c6c 0x185a53280 0x185a45aa8 0x185a5a0b0 0x185a63174 0x184308d90 0x1842d8940 0x1842ddc68 0x181d7d030 0x181d8dcf0 0x181cc7ff8 0x181ccd804 0x181ce13c8 0x19d4f238c 0x184687060 0x184404b8c 0x10544d8d0 0x106699a24)
libc++abi: terminating with uncaught exception of type NSException
dyld4 config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'the view returned from -collectionView:viewForSupplementaryElementOfKind:atIndexPath: does not match the element kind it is being used for. When asked for a view of element kind 'UICollectionElementKindSectionFooter' the data source dequeued a view registered for the element kind 'UICollectionElementKindSectionHeader'.'
terminating with uncaught exception of type NSException

5.UIView不生成对象设置颜色闪退。

有问题的代码:

- (instancetype)initWithFrame:(CGRect)frame underlineColor:(UIColor *)underlineColor TitleArr:(NSMutableArray *)titleArr textColor:(UIColor *)textColor selectTextColor:(UIColor *)selectTextColor
{
    self.backgroundColor = [UIColor clearColor];
    self = [super initWithFrame:frame];
    if (self)
    {
        [self initSubPanelWithTitleArr:titleArr underlineColor:underlineColor textColor:textColor selectTextColor:selectTextColor];
    }
    return self;
}

修改后的代码:

- (instancetype)initWithFrame:(CGRect)frame underlineColor:(UIColor *)underlineColor TitleArr:(NSMutableArray *)titleArr textColor:(UIColor *)textColor selectTextColor:(UIColor *)selectTextColor
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self initSubPanelWithTitleArr:titleArr underlineColor:underlineColor textColor:textColor selectTextColor:selectTextColor];
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}

闪退日志:

2021-11-11 13:36:59.511303+0800 光予露家长端[54977:3108685] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UIView is missing its initial trait collection populated during initialization. This is a serious bug, likely caused by accessing properties or methods on the view before calling a UIView initializer. View: <BGCommonScrollToolPanel: 0x1070592e0; frame = (0 0; 0 0); transform = [0, 0, 0, 0, 0, 0]; anchorPoint = (0, 0); alpha = 0; opaque = NO; layer = (null)>'
*** First throw call stack:
(0x181d5b05c 0x19a275f54 0x18361cb04 0x1853fbf54 0x1842d35f0 0x1845fca9c 0x10545b95c 0x105336b44 0x18431fbdc 0x185227b30 0x1842e0008 0x18457f814 0x1844c5608 0x18441b334 0x1842e963c 0x1842f9c6c 0x185a53280 0x185a45aa8 0x185a5a0b0 0x185a63174 0x185a45210 0x181d03570 0x181cd2854 0x181ccd8ec 0x181ce13c8 0x19d4f238c 0x184687060 0x184404b8c 0x1053518d0 0x106655a24)
libc++abi: terminating with uncaught exception of type NSException
dyld4 config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UIView is missing its initial trait collection populated during initialization. This is a serious bug, likely caused by accessing properties or methods on the view before calling a UIView initializer. View: <BGCommonScrollToolPanel: 0x1070592e0; frame = (0 0; 0 0); transform = [0, 0, 0, 0, 0, 0]; anchorPoint = (0, 0); alpha = 0; opaque = NO; layer = (null)>'

6.iOS 15 的 UITableView section header多22像素问题

iOS 15 的 UITableView又新增了一个新属性:sectionHeaderTopPadding 会给每一个section header 增加一个默认高度,当我们 使用 UITableViewStylePlain 初始化 UITableView的时候,就会发现,系统给section header增高了22像素。

解决办法:

if (@available(iOS 15.0, *)) {
    tableView.sectionHeaderTopPadding = 0;
}

7.The file “xxx.entitlements” could not be opened. Verify the value of the CODE_SIGN_ENTITLEMENTS build setting for target “xxxxxx” and build configuration “debug” is correct and that the file exists on disk. (in target “xxxxxx”)


解决方法:

1、百度很多教程都是说证书配合问题,只需要在capability中的推送开关, 关闭然后在打开就好了;


但是我遇到的问题中,修改了项目名和类名后,在capability中的推送的扩展Push Notifications不见了,在点击 +Capability 按钮去添加Push Notifications模块时,居然双击添加后,居然添加不上,不知道是不是Xcode(version - 11.3.1)的问题,最终自己通过下面的方法解决问题。


2、打开项目,选择target中对应的项目target, 选择 Build Setting,在搜索中输入 enti 简写,然后找到 Signing 下的 Code Signing Entitlements 中的xxx/xxx.entitlements 修改成你app的名称,如:xxx/app名称.entitlements, 重新编译就可以了;或者你直接删掉 Signing 下的 Code Signing Entitlements 中的xxx/xxx.entitlements,然后重新编译也可以。


目录
打赏
0
0
0
0
54
分享
相关文章
安卓与iOS开发环境的差异及适配策略
在移动应用开发的广阔舞台上,Android和iOS两大操作系统各据一方,各自拥有独特的开发环境和工具集。本文旨在深入探讨这两个平台在开发环境上的关键差异,并提供有效的适配策略,帮助开发者优化跨平台开发流程。通过比较Android的Java/Kotlin和iOS的Swift/Objective-C语言特性、IDE的选择、以及API和系统服务的访问方式,本文揭示了两个操作系统在开发实践中的主要分歧点,并提出了一套实用的适配方法,以期为移动开发者提供指导和启示。
iOS字体像素与磅的对应关系
iOS字体像素与磅的对应关系
177 1
|
10月前
|
SwiftUI适配iOS16导航控制器引起的闪退
SwiftUI适配iOS16导航控制器引起的闪退
93 0
|
10月前
|
iOS UITableViewCell刷新某些行的cell或section
iOS UITableViewCell刷新某些行的cell或section
97 0
Donut多端框架小程序打包适配ios和安卓app
腾讯新出了一个 Donut 多端框架,可以直接将微信小程序转成 ios 和 安卓 app,小程序开发者工具里也集成了 app 相关升级、调试和打包的功能,终于可以一套代码开发出3个客户端了!
303 0
Donut多端框架小程序打包适配ios和安卓app
iOS UITableView(列表)
UITableView UITableView内置了两种样式:UITableViewStylePlain,UITableViewStyleGrouped 里的方法: tableView处理步骤 #pragma mark 1.
1441 0

热门文章

最新文章

  • 1
    【01】噩梦终结flutter配安卓android鸿蒙harmonyOS 以及next调试环境配鸿蒙和ios真机调试环境-flutter项目安卓环境配置-gradle-agp-ndkVersion模拟器运行真机测试环境-本地环境搭建-如何快速搭建android本地运行环境-优雅草卓伊凡-很多人在这步就被难倒了
    70
  • 2
    【03】仿站技术之python技术,看完学会再也不用去购买收费工具了-修改整体页面做好安卓下载发给客户-并且开始提交网站公安备案-作为APP下载落地页文娱产品一定要备案-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-优雅草卓伊凡
    8
  • 3
    【02】仿站技术之python技术,看完学会再也不用去购买收费工具了-本次找了小影-感觉页面很好看-本次是爬取vue需要用到Puppeteer库用node.js扒一个app下载落地页-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-优雅草卓伊凡
    6
  • 4
    Cellebrite UFED 4PC 7.71 (Windows) - Android 和 iOS 移动设备取证软件
    8
  • 5
    【01】仿站技术之python技术,看完学会再也不用去购买收费工具了-用python扒一个app下载落地页-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-客户的麻将软件需要下载落地页并且要做搜索引擎推广-本文用python语言快速开发爬取落地页下载-优雅草卓伊凡
    8
  • 6
    iOS各个证书生成细节
    8
  • 7
    iOS|记一名 iOS 开发新手的前两次 App 审核经历
    12
  • 8
    解决 input 输入框在 iOS 系统中无法输入内容
    10
  • 9
    iOS - Swift NSPoint 位置
    1
  • 10
    iOS:应用程序的线程安全性
    2