開発中に落ちた小さな穴を記録します
2604 ワード
1、ページジャンプは、ViewDidLoadではできません.例えば、次のコードです.
このコードはがっかりして、ジャンプしません.ジャンプを別のライフサイクル関数、または他のイベントメソッドに書き込むとよい.
2、サードパーティ製キーボードの高さの問題
プロジェクトではUItextView入力バーが使用されていますが、キーボードがイジェクトされるとUItextViewがブロックされるため、キーボードのイジェクトを処理する必要があります.具体的には、システムからキーボードに関する通知をリスニングすることです.同じ通知でポップアップと終了を傍受してもよいし、別々に傍受してもよい.通知の辞書のkey値に基づいてキーボードの高さを取得し、frameを調整したり、制約を変更したりすることができます.
問題が来た.
サードパーティ入力方式、例えば私が使用している検索入力方式、iOS 9.3.5、iPhone 5、システムは3つの通知を出して、3つの高さを与えるので、画面の上の黒い領域がキラキラしていて、体験に影響します.通知の内容は次のとおりです.
3回取得した高さは0216256です.解決策は、3回目に取得した値のみを使用します.具体的な操作はいろいろありますが、UIKEyboardFrameEndUserInfoKeyで取得した高さからUIKEyboardFrameBeginUserInfoKeyで取得した高さを差し引くと、差は100未満で、高さは0より大きく、3回目に取得した値とみなされます.
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor blueColor];
SViewController *sc = [[SViewController alloc] init];
[self presentViewController:sc animated:YES completion:nil];
}
このコードはがっかりして、ジャンプしません.ジャンプを別のライフサイクル関数、または他のイベントメソッドに書き込むとよい.
2、サードパーティ製キーボードの高さの問題
プロジェクトではUItextView入力バーが使用されていますが、キーボードがイジェクトされるとUItextViewがブロックされるため、キーボードのイジェクトを処理する必要があります.具体的には、システムからキーボードに関する通知をリスニングすることです.同じ通知でポップアップと終了を傍受してもよいし、別々に傍受してもよい.通知の辞書のkey値に基づいてキーボードの高さを取得し、frameを調整したり、制約を変更したりすることができます.
問題が来た.
サードパーティ入力方式、例えば私が使用している検索入力方式、iOS 9.3.5、iPhone 5、システムは3つの通知を出して、3つの高さを与えるので、画面の上の黒い領域がキラキラしていて、体験に影響します.通知の内容は次のとおりです.
2016-09-02 15:20:20.752 [2898:1049771] {
UIKeyboardAnimationCurveUserInfoKey = 7;
UIKeyboardAnimationDurationUserInfoKey = "0.25";
UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 0}}";
UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 568}";
UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 568}";
UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 568}, {320, 0}}";
UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 568}, {320, 0}}";
UIKeyboardIsLocalUserInfoKey = 1;
}
2016-09-02 15:20:21.005 [2898:1049771] {
UIKeyboardAnimationCurveUserInfoKey = 7;
UIKeyboardAnimationDurationUserInfoKey = 0;
UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 216}}";
UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 568}";
UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 460}";
UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 568}, {320, 0}}";
UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 352}, {320, 216}}";
UIKeyboardIsLocalUserInfoKey = 1;
}
2016-09-02 15:20:21.125 [2898:1049771] {
UIKeyboardAnimationCurveUserInfoKey = 7;
UIKeyboardAnimationDurationUserInfoKey = 0;
UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 256}}";
UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 460}";
UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 440}";
UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 352}, {320, 216}}";
UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 312}, {320, 256}}";
UIKeyboardIsLocalUserInfoKey = 1;
}
3回取得した高さは0216256です.解決策は、3回目に取得した値のみを使用します.具体的な操作はいろいろありますが、UIKEyboardFrameEndUserInfoKeyで取得した高さからUIKEyboardFrameBeginUserInfoKeyで取得した高さを差し引くと、差は100未満で、高さは0より大きく、3回目に取得した値とみなされます.