隨著iPhone 8和iPhone X 以及iOS 11 的發布更新,更新適配的工作又開始了??
首先更新到了Xcode 9 ,具體暫時發現了以下新功能
無線調試
?? ?? 看見旁邊的安卓調試還在用數據線連接頓時感覺高大上有沒有!!
想使用無線調試的首要條件是更新到Xcode 9 和 iOS 11
然后按圖所示打開
勾選上Connect via network
當左邊有小地球的時候表示已經連接
然后可以拔掉數據線,開始裝13之旅!
?? ?? 如果有報錯,請先將手機設置密碼,然后連接上在取消就好了,具體的報錯內容忘記保存了?? ??
多個模擬器調試
Xcdoe 9可以允許多個模擬器同時運行調試
然后就可以左手一個iPhone 8 右手一個iPhone X
快捷鍵更改
以前快速進入方法command+鼠標單擊
現在會彈出一個菜單有不同的操作
如果想變回以前的操作
只需要設置一下就可以了
新增AR開發
xcode 9手動帶入第三方遇見的坑
由于項目沒有使用pod,最近發現有第三方更新,于是手動導入了一下,結果一直報錯,后來發現是Build Phases --->Compile Sources 里面.m文件沒有自動導入。。
Xcode 9 的其他的暫時沒有什么新發現,歡迎大家補充!!!
下面介紹iOS 11 適配(不包括iPhone X)
searchBar 變高
以前使用self.navigationItem.titleView = searchBar; 的小伙伴會發現titleView 高度變高
我使用的解決方法是
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH - 80, 44)];
// container.backgroundColor = [UIColor redColor];
mySearchBar.translatesAutoresizingMaskIntoConstraints = NO;
[container addSubview:mySearchBar];
// self.navigationItem.titleView = container;
self.navigationItem.titleView = mySearchBar;
// 設成container會導致searchBar無響應事件,暫時還不清楚問題原因,
[mySearchBar mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.equalTo(SCREEN_WIDTH - 100);
make.height.equalTo(34);
make.centerX.equalTo(container);
make.centerY.equalTo(container);
}];
或者 使用 Navigation 集成的 UISearchController
self.navigationItem.searchController = mySearchController;
大標題的顯示
在UI NavigationBar中,新增了一個屬性prefersLargeTitles,將該屬性設置為ture,NavigationBar會顯示大標題.
navigationController?.navigationBar.prefersLargeTitles = true
Tableview Footer Header View
iOS 11 中發現之前設定的footerView 或者headerView 高度都變了。
解決方法:
如果調用了:
#pragma mark tableview delegate
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 10;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 10;
}
方法必須實現:
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
return nil;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
return nil;
}
或者
estimaterRowHeight = 0;
estimaterSectionHeaderHeight = 0;
estimaterSectionFooterHeight = 0;
這是因為
estimaterRowHeight
estimaterSectionHeaderHeight
estimaterSectionFooterHeight
高度估算屬性由默認0變成
UITableViewAutomaticDimension
所致
iOS 11 導致的定位失敗問題
因為蘋果現在增加了一項新的隱私保護功能
NSLocationAlwaysAndWhenInUseUsageDeion
并且原有的
NSLocationAlwaysUsageDeion
被降級為
NSLocationWhenInUseUsageDeion。
想要達到之前
NSLocationAlwaysUsageDeion
的定位效果,需要在info.plist文件中添加
NSLocationAlwaysAndWhenInUseUsageDeion 和 NSLocationWhenInUseUsageDeion
兩個就可以了
iPhone X 適配注意事項
1.隱藏導航欄的界面特別要注意,因為“耳朵”和 Safe Area 的原因,很有可能上面會露出小片空白。
2.列表頁如果沒有 tabBar,而且列表頁可以拉到最底下,請在列表頁最后留一點空白給手勢區域。
3.列表頁使用系統的 tabBar 那是完全自動適配的,但如果是自定義的 tabBar,請適當在 tabBar 底下留出空白給手勢區域。
暫時就發現這些問題,有興趣的朋友建議大家去看看WWDC 傳送門
歡迎指正錯誤或者提出意見建議!