iOS 11はiPhoneとの相性がいいです.
4514 ワード
iOS 11適応
1.ナビゲーションバーがボタンの位置に戻る問題(17-12-01初めての変更)
ソリューション:navigationItemを書き換え、Ubttonのオフセットを変えて制御したり、自動レイアウトを使って制御したりします.第一の方法:http://www.jianshu.com/p/26fc39135c34 参照記事リンク:AppはiOS 11に適合し、著者zhao 0
位置決め権限の問題:
1.ナビゲーションバーの高さ問題(17-12-01初めての変更)
まず、ios 11の前に、ナビゲーションバーの高さは64 ptで、つまりnav(44 pt)+status(20 pt)です.しかし、ios 11からは大きなタイトル(prefers Larget Titles)が追加され、prefers LargetTitles=yesを設定してデフォルトは96 ptとなり、逆に64 ptとなります.iPhone X上のステータスバーの20 ptを44 ptに変更しました.したがって、ナビゲーションバーの高さを判断する必要があります.常用マクロは以下の通りです.
iphone Xでは、ダイナミックな高さを使わず、スクリーンスケールを含めたコードの制約もできません.
以上、良い提案とご指摘がありましたら、ぜひボードを撮ってください.ありがとうございます.
1.ナビゲーションバーがボタンの位置に戻る問題(17-12-01初めての変更)
ソリューション:navigationItemを書き換え、Ubttonのオフセットを変えて制御したり、自動レイアウトを使って制御したりします.第一の方法:http://www.jianshu.com/p/26fc39135c34 参照記事リンク:AppはiOS 11に適合し、著者zhao 0
UIImage *backImage = [[UIImage imageNamed:@"top_arrows"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
self.navigationBar.backIndicatorImage = backButtonImage;
self.navigationBar.backIndicatorTransitionMaskImage = backButtonImage;
第二の方法: nav - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.titleLabel.font = [UIFont systemFontOfSize:18];
[button setBackgroundImage:[UIImage imageNamed:@"top_arrows"] forState:UIControlStateNormal];
// [button setImage:[UIImage imageNamed:@"top_arrows"] forState:UIControlStateNormal];
// [button setImage:[UIImage imageNamed:@"top_arrows"] forState:UIControlStateHighlighted];
button.size = CGSizeMake(12, 20);
//
button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
// 10
button.contentEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
// item
viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
2.UITTable Viewのセレクションの間隔が大きすぎる問題-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 15.0f;// , 0.001f
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0.001f;
}
// Group section
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
return [[UIView alloc] init];
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
return [[UIView alloc] init];
}
3.TableViewのオフセット問題、iPhone上のMJRefreshオフセット問題.//self.automaticallyAdjustsScrollViewInsets = NO;
if (@available(iOS 11.0, *)) {
// mjrefresh bug
self.mainTableView.estimatedRowHeight = 0;
self.mainTableView.estimatedSectionHeaderHeight = 0;
self.mainTableView.estimatedSectionFooterHeight = 0;
} else {
// Fallback on earlier versions
}
4.権限問題位置決め権限の問題:
NSLocationAlwaysUsageDescription
、NSLocationWhenInUseUsageDescription
、NSLocationAlwaysAndWhenInUsageDescription
.アルバムのパーミッション問題:NSCameraUsageDescription
、NSPhotoLibraryAddUsageDescription
、NSPhotoLibraryUsageDescription
5.ナビゲーションバーにsearchbarを追加するとナビゲーションバーの高さが増加します.具体的な処理は以下の通りです.2018-02-07日編集UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 32)];
UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:titleView.bounds];
searchBar.placeholder = @" ";
searchBar.searchBarStyle = UISearchBarStyleMinimal;
[titleView addSubview:searchBar];
self.navigationItem.titleView = titleView;
iPhoneの適応問題:1.ナビゲーションバーの高さ問題(17-12-01初めての変更)
まず、ios 11の前に、ナビゲーションバーの高さは64 ptで、つまりnav(44 pt)+status(20 pt)です.しかし、ios 11からは大きなタイトル(prefers Larget Titles)が追加され、prefers LargetTitles=yesを設定してデフォルトは96 ptとなり、逆に64 ptとなります.iPhone X上のステータスバーの20 ptを44 ptに変更しました.したがって、ナビゲーションバーの高さを判断する必要があります.常用マクロは以下の通りです.
// iPhone X
#define isIPhoneX (SCREEN_WIDTH == 375.f && SCREEN_HEIGHT == 812.f)
// iphoneX
#define NaviH (screenH == 812 ? 88 : 64) // 812 iPhoneX
#define StatusBarHeight (isIPhoneX ? 44.f : 20.f)//
2 Tabbaar Controllerが2級のインターフェースにジャンプするのは上にシフトする問題です.// tabBra frame
nav - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
if (isIPhoneX)// push tabbar
{
CGRect frame = self.tabBarController.tabBar.frame;
frame.origin.y = [UIScreen mainScreen].bounds.size.height - frame.size.height;
self.tabBarController.tabBar.frame = frame;
}
3.テーブルビューに画面が表示されない問題.iphone Xでは、ダイナミックな高さを使わず、スクリーンスケールを含めたコードの制約もできません.
以上、良い提案とご指摘がありましたら、ぜひボードを撮ってください.ありがとうございます.