1.自定義導(dǎo)航欄按鈕,設(shè)置了按鈕frame,但是如果按鈕圖片本身大小比按鈕大,導(dǎo)航欄的按鈕就會(huì)被撐開,如下圖

解決方法:
[leftBtn.widthAnchor ? constraintEqualToConstant: ?20 ].active = YES;
[leftBtn.heightAnchor ? constraintEqualToConstant: 20].active = YES;

2.IphoneX 網(wǎng)絡(luò)類型獲取報(bào)錯(cuò)
一直以來都是通過以下這種方式進(jìn)行網(wǎng)絡(luò)方式的獲取
UIApplication * app = [UIApplication sharedApplication];
NSArray * subviews = [[[app valueForKey:@"statusBar"] valueForKey:@"foregroundView"] subviews];
在ios11系統(tǒng)除IPhoneX上都能正常運(yùn)行,在iphoneX報(bào)錯(cuò)如下:
this class is not key value coding-compliant for the key foregroundView.'

解決方式:
? 其實(shí)打斷點(diǎn)一層一層的點(diǎn)擊查看,可以看出在iphoneX上的statusBar上下又套了一層,所以在沒有取到的時(shí)候再取一次就可以了
if ([[app valueForKeyPath:@"_statusBar"] isKindOfClass:NSClassFromString(@"UIStatusBar_Modern")]) {
subviews = [[[[app valueForKeyPath:@"_statusBar"] valueForKeyPath:@"_statusBar"] valueForKeyPath:@"foregroundView"] subviews];
} else {
subviews = [[[app valueForKeyPath:@"_statusBar"] valueForKeyPath:@"foregroundView"] subviews];
}

最后想說一點(diǎn)就是:其實(shí)網(wǎng)絡(luò)方式的獲取最好更換成蘋果官方演示demo的方式,這樣才能確保不會(huì)出現(xiàn)問題;方法如下:
點(diǎn)擊這個(gè)鏈接,然后點(diǎn)擊Download Sample Code下載整個(gè)代碼,將下載的demo中的Reachability.h和.m復(fù)制到自己的項(xiàng)目中,再導(dǎo)入SystemConfiguration.framework框架,導(dǎo)入步驟:點(diǎn)擊項(xiàng)目名-Build Phases-展開Link Binary With Libraries-點(diǎn)擊加號(hào),找到這個(gè)框架添加即可;框架添加完畢后在自己需要的文件中import ??Reachability.h,代碼如下:
+(void)dataNetworkTypeFromStatusBar{
? ? ? ? ? Reachability *reachability? = [Reachability reachabilityWithHostName:@"www.apple.com"];
? ? ? ? ?NetworkStatus internetStatus = [reachability currentReachabilityStatus];
? ? ? ? NSString *net = @"WIFI";
? ? ? ? ? ? ? switch (internetStatus) {
? ? ? ? ? ? ? ? ? ?case ReachableViaWiFi:
? ? ? ? ? ? ? ? ? ? ? ? ? ? net = @"WIFI";
? ? ? ? ? ? ? ? ? ? ? ? ? ?[UserDefault setInteger:1 forKey:NetOfKey];
? ? ? ? ? ? ? ? ? ? ? ? ? ?break;
? ? ? ? ? ? ? ? ?case ReachableViaWWAN:
? ? ? ? ? ? ? ? ? ? ? ? ? ?net = @"蜂窩數(shù)據(jù)";
? ? ? ? ? ? ? ? ? ? ? ? ? ?[UserDefault setInteger:1 forKey:NetOfKey];
? ? ? ? ? ? ? ? ? ? ? ? ? //net = [self getNetType];? //判斷具體類型
? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case NotReachable:
? ? ? ? ? ? ? ? ? ? ? ? ? net = @"無網(wǎng)絡(luò)";
? ? ? ? ? ? ? ? ? ? ? ? ? [UserDefault setInteger:0 forKey:NetOfKey];
? ? ? ? ? ? ?default:
? ? ? ? ? ? ? ? ? ? ? ? ?break;
? ? ? ? ? }
}
如果想要判斷網(wǎng)絡(luò)的具體類型就要用到CoreTelephony.framework框架,還按照上面的步驟導(dǎo)入這個(gè)框架,然后在需要用的地方#import ?<CoreTelephony/CTTelephonyNetworkInfo.h>?
具體代碼如下:
+ (NSString *)getNetType
{
? ? ? ? CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfo alloc] init];
? ? ? ? NSString *currentStatus = info.currentRadioAccessTechnology;
? ? ? ? NSString *netconnType = @"4G";
? ? ? ?if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyGPRS"]) {
? ? ? ? ? ? ? ? ? ?netconnType = @"GPRS";
? ? ? ? }else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyEdge"]) {
? ? ? ? ? ? ? ? ? netconnType = @"2.75G EDGE";
? ? ? ? }else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyWCDMA"]){
? ? ? ? ? ? ? ? ? netconnType = @"3G";
? ? ? ? }else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyHSDPA"]){
? ? ? ? ? ? ? ? ? netconnType = @"3.5G HSDPA";
? ? ? ? }else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyHSUPA"]){
? ? ? ? ? ? ? ? ? netconnType = @"3.5G HSUPA";
? ? ? ? }else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyCDMA1x"]){
? ? ? ? ? ? ? ? ? netconnType = @"2G";
? ? ? ? }else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyCDMAEVDORev0"]){
? ? ? ? ? ? ? ? ? ?netconnType = @"3G";
? ? ? ? ?}else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyCDMAEVDORevA"]){
? ? ? ? ? ? ? ? ? ?netconnType = @"3G";
? ? ? ? ?}else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyCDMAEVDORevB"]){
? ? ? ? ? ? ? ? ? ?netconnType = @"3G";
? ? ? ? ?}else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyeHRPD"]){
? ? ? ? ? ? ? ? ? netconnType = @"HRPD";
? ? ? ? ?}else if ([currentStatus isEqualToString:@"CTRadioAccessTechnologyLTE"]){
? ? ? ? ? ? ? ? ? ?netconnType = @"4G";
? ? ? ? ?}
? ? ? ? ?return netconnType;
}