开发中遇到的问题及解决办法

2017-09-15  本文已影响103人  麦子_KB

1.启动app存在的一些问题

 2.1、若用户直接启动,lauchOptions内无数据;
 2.2、若由其他应用程序通过openURL:启动,则UIApplicationLaunchOptionsURLKey对应的对象为启动URL(NSURL),UIApplicationLaunchOptionsSourceApplicationKey对应启动的源应用程序的bundle ID (NSString);
 2.3、若由本地通知启动,则UIApplicationLaunchOptionsLocalNotificationKey对应的是为启动应用程序的的本地通知对象(UILocalNotification);
 2.4、若由远程通知启动,则UIApplicationLaunchOptionsRemoteNotificationKey对应的是启动应用程序的的远程通知信息userInfo(NSDictionary);
 2.5、其他key有UIApplicationLaunchOptionsAnnotationKey,UIApplicationLaunchOptionsLocationKey, UIApplicationLaunchOptionsNewsstandDownloadsKey。

2.tableView嵌套问题

- (Bool)GestureRecognizer:(UIGestureRecognizer *)gestureRecoginzer shouldReceiveTouch:(UITouch *)touch {
  if([touch.view isKindOfClass:[UILabel class]] ){
        return YES;
    } else {
        return NO;
    }
  }

3.适配iOS 11遇到的问题及解决办法

Self-Sizing by Default
NEW
 Link on iOS 11, all estimated heights default to UITableViewAutomaticDimension Headers, footers, and cells use self-sizing by default
iOS only—behavior is not changed on tvOS
Ensure all views have sufficient internal constraints
Return fixed sizes from delegate methods

此时需要设置:

tableView.estimatedRowHeight = 0;
tableView.estimatedSectionHeaderHeight = 0 ;
tableView.estimatedSectionFooterHeight = 0;

if (systemVersion >= 11) {
   self.tableView.contentInsetAdjustmentBehavior  = UIScrollViewContentInsetAdjustmentNever;
} else {
   self.automaticallyAdjustsScrollViewInsets = NO;
}

4.获取相册权限

    <key>NSPhotoLibraryAddUsageDescription</key>  //iOS 11
    <string>App需要您的同意,才能访问相册</string>  
    <key>NSPhotoLibraryUsageDescription</key>
    <string>App需要您的同意,才能访问相册</string>   //<iOS10

5.导航栏

iOS11对导航栏做了比较大的更改:

//设置导航栏返回按钮,iOS11上颜色会被冲掉
- (void)setNavigationBarBackButtonItem:(NSString *)image {
    UIImage *backImage = [UIImage imageNamed:image];
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:backImage style:UIBarButtonItemStylePlain target:self action:@selector(popViewControllerAnimated)];
    backItem.tintColor = [UIColor colorWithPatternImage:backImage];
    backItem.title = @"";
    self.navigationItem.leftBarButtonItem = backItem;
}

用 initWithCustomView的方法,不会受上面影响。

  _leftBtn = [[UIButton alloc] ];
    [_leftBtn setImage:image forState:UIControlStateNormal];
    _leftBtn.backgroundColor = [UIColor cyanColor];
    _leftBtn.imageView.contentMode = UIViewContentModeScaleAspectFit;
    _leftBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    [_leftBtn addTarget:self action:@selector(leftBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_leftBtn];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;

6、iOS 10无法连接网络问题

有些时候在iOS10系统下,App无论如何都无法连接互联网,这时候是因为我们的App没有向用户发出是否允许网络请求,我们可以按照以下操作让App弹出是否允许网络请求:

设置-无线局域网或蜂窝移动网络-使用无线局域网与蜂窝移动的移动
更改任意App的权限再恢复原先选项,操作完成后再打开相关问题应用,会弹出选择网络,确认即可

上一篇 下一篇

猜你喜欢

热点阅读