iOS之旅--iOS11的一些适配工作

来源:互联网 发布:linux vi编译 编辑:程序博客网 时间:2024/06/15 08:04
  • 跳转App Store评论
- (void)gotoAppStoreEvaluate{//1028355284是我们APP的appID,替换成你的应用的appID即可    NSString *itunesUrl = @"itms-apps://itunes.apple.com/cn/app/id1028355284?mt=8&action=write-review";    NSURL * url = [NSURL URLWithString:itunesUrl];    if ([[UIApplication sharedApplication] canOpenURL:url]) {        [[UIApplication sharedApplication]openURL:url];    } else {        NSLog(@"can not open");    }}
  • UISearchBar的修改
    之前的searchbar高度为44使用,现在iOS11之后,高度是56不能改变(目前没有找到修改高度的办法)。兼容一下在iOS11上搜索框的高度设置为56了。

    NSInteger sbHeight = 44;if (@available(iOS 11, *)) {  sbHeight = 56;}
  • UITableView和UIScrollView的修改

    // tableView 偏移20/64适配if (@available(iOS 11.0, *)) {    self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;//UIScrollView也适用} else {    self.automaticallyAdjustsScrollViewInsets = NO;}
  • UIToolBar 在iOS11之后默认添加了_UIToolbarContentView,里面有点击事件,会把自己定义的点击事件拦截。 可以在封装的view里面这样处理。如果代码没有封装全部在控制器里面,有另外一种办法,可以自行百度。

    - (void)layoutSubviews {[super layoutSubviews];NSArray *subViewArray = [self subviews];for (id view in subViewArray) {    if ([view isKindOfClass:(NSClassFromString(@"_UIToolbarContentView"))]) {        UIView *testView = view;        testView.userInteractionEnabled = NO;    }}}
  • 未完待续(近期工作任务比较多,慢慢更新)

原创粉丝点击