iOS 11とXcode 9の試用後の一部の問題のまとめ
3032 ワード
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
if (section == 0) {
return 0.001;
}
return 30;
}
修正方法は次のとおりです.
if (@available(iOS 11.0, *)) {
self.tableView.estimatedRowHeight = 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.estimatedSectionFooterHeight = 0;
}
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
return nil;
}
#endif
はい、nilを返しても高さ設定が有効になります.
// UIToolbar, rectButton、circleButton buttonClick:
UIToolbar *markToolBar = [[UIToolbar alloc] initWithFrame:CGRectZero];
UIBarButtonItem *rectItem = [[UIBarButtonItem alloc] initWithCustomView:self.rectButton];
UIBarButtonItem *circleItem = [[UIBarButtonItem alloc] initWithCustomView:self.circleButton];
UIBarButtonItem *flexibleitem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:(UIBarButtonSystemItemFlexibleSpace) target:self action:nil];
NSArray *items = @[rectItem,flexibleitem,circleItem];
[markToolBar setItems:items animated:YES];
ここでbuttonをクリックするとbuttonの座標iOS 11を得る必要があります.
-(void)buttonClick:(UIButton *)sender { CGRect viewFrame = sender.frame; }
Xcode 9を使用するiOS 11のシミュレータでは、このようにして得られる座標は(0,0,30,30)である.問題が発見されたでしょう、CGPointは(0,0)である.これは間違っている.仕方なく、このように変えて、生きているうちに使うしかありません.
-(void)buttonClick:(UIButton *)sender { CGRect viewFrame = [sender convertRect:sender.bounds toView:self]; }
キーワード:Xcode、ネイティブコンパイル通過、シミュレータコンパイル失敗
まず,コードは問題なく,以前に使用した場合,実機でもシミュレータでも正常に使用されていた.これにより、あるライブラリがシミュレータをサポートしていない場合を排除します.シミュレータを使用してコンパイルすると、ヒントの問題は
lexical or preprocessor issue“xxx.h”file not foundはこれらのエラープロンプトに似ています.
毎回の再起動シミュレータを経て、Xcodeを再起動して、パソコンを再起動して、脳を再起動して、再起動して......最後の解決策は、ローカルコンピュータでシミュレータキャッシュファイルを消去することです.
キーワード:UITableView、UIcollectionView Appdelegate.mのdidFinishLaunchingWithOptions:メソッドに次のコードを追加すると、iOS 11のUItableViewとUIcollectionViewをグローバルに適合させることができます.
if (@available(ios 11.0,*)) {
UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
UITableView.appearance.estimatedRowHeight = 0;
UITableView.appearance.estimatedSectionFooterHeight = 0;
UITableView.appearance.estimatedSectionHeaderHeight = 0;
}
iOSの更新のたびに、硝煙のない戦争が行われています.しかし、私はこの戦争が好きです.私も参加者だからです.何?また似合う?!はい、少々お待ちください.このお茶を飲みました.