iOS11設(shè)備上tableview分割線(xiàn)的問(wèn)題

最近為了適配iOS 11,碰到一些問(wèn)題?,F(xiàn)在ipa基于iOS SDK 9 運(yùn)行在iOS11.1上發(fā)現(xiàn)tableview的分割線(xiàn)不能訂到兩邊。查閱資料特將解決辦法分享一下!
//
// UITableView+NASeparatorInset.m
// iPoS_IOS
//
// Created by Jason on 17/11/7.
// Copyright ? 2017年 Treasure Frontier System Sdn. Bhd. All rights reserved.
//

import "UITableView+NASeparatorInset.h"

import <objc/runtime.h>

@implementation UITableView (NASeparatorInset)

  • (void)load {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
    Class class = [self class];

      SEL originalSelector = @selector(initWithFrame:style:);
      SEL swizzledSelector = @selector(initWithNAFrame:style:);
      
      Method originalMethod = class_getInstanceMethod(class, originalSelector);
      Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
      
      BOOL success = class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
      if (success) {
          class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
      } else {
          method_exchangeImplementations(originalMethod, swizzledMethod);
      }
    

    });
    }

  • (instancetype)initWithNAFrame:(CGRect)frame style:(UITableViewStyle)style{
    UITableView *tableView=nil;

    if ([self respondsToSelector:@selector(initWithNAFrame:style:)]) {
    tableView= [self initWithNAFrame:frame style:style];
    }
    if([tableView respondsToSelector:@selector(setCellLayoutMarginsFollowReadableWidth:)])
    {
    tableView.cellLayoutMarginsFollowReadableWidth = NO;
    }
    if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {
    [tableView setSeparatorInset:UIEdgeInsetsZero];
    }
    if ([tableView respondsToSelector:@selector(setLayoutMargins:)]) {
    [tableView setLayoutMargins:UIEdgeInsetsZero];
    }

    return tableView;

}

@end

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 轉(zhuǎn)載:http://www.cocoachina.com/ios/20161102/17920.html 因?yàn)镺b...
    F麥子閱讀 700評(píng)論 0 1
  • 1、禁止手機(jī)睡眠[UIApplication sharedApplication].idleTimerDisabl...
    DingGa閱讀 1,199評(píng)論 1 6
  • 本文轉(zhuǎn)載自:http://yulingtianxia.com/blog/2014/11/05/objective-...
    ant_flex閱讀 867評(píng)論 0 1
  • 轉(zhuǎn)載:http://yulingtianxia.com/blog/2014/11/05/objective-c-r...
    F麥子閱讀 827評(píng)論 0 2
  • 氧化:臭氧注入椎間盤(pán)后能迅速氧化髄核內(nèi)的蛋白多糖,使髄核細(xì)胞模和細(xì)胞內(nèi)結(jié)構(gòu)破壞,造成細(xì)胞變性壞死,細(xì)胞合成和分泌蛋...
    穎茜閱讀 291評(píng)論 0 1

友情鏈接更多精彩內(nèi)容