hackiftekhar / IQKeyboardManager

Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView. Neither need to write any code nor any setup required and much more.
MIT License
16.46k stars 2.41k forks source link

Bug: When use UISheetPresentationController, UI components raised more that i expected #1994

Closed hyun99999 closed 11 months ago

hyun99999 commented 11 months ago

Describe the bug When present UIViewController that has sheetPresentationController property. A keyboard raised UI components more that i expected. I use keyboard becomeFirstResponder() in viewWillAppear(). In IQKeyboardManager 6.5.15 normally works, but in 6.5.16 it doesn't works.

UISheetPresentationController supports automatic keyboard avoidance. Wouldn't it have been a conflict because it played the same role twice?

To Reproduce

just present UIViewController that has sheetPresentationController property.

Expected behavior

Screenshots

Versions

Xcode: Version 15.0.1 (15A507) Mac OS: 14.1 Simulator/Device: 17.0 Simulator/Device Name: iPhone 15 Library Version: 6.5.16

hackiftekhar commented 11 months ago

It might be. Can you please share the code which needs to be added before presentation to reproduce this issue?

hyun99999 commented 11 months ago

Sure why not! Use next code to present bottom sheet that has medium detent.

// ViewController has UITextField.
let sheet = ViewController()

if let sheet = sheet.sheetPresentationController {
    // set detents
    sheet.detents = [.medium()]
}

present(sheet, animated: true)

Next, touch UITextField to raise keyboard. boom, you can meet that it happend.

ideviftekhar commented 11 months ago

Thanks, I'll take a look at it.

hackiftekhar commented 11 months ago

@hyun99999 This might be because you are writing becomeFirstResponder() in viewWillAppear. When this function is called the view is not added to the window hierarchy.

I would suggest to move becomeFirstResponder(0 to viewDidAppear() because the view is properly configured and appeared in the UI.

hyun99999 commented 11 months ago

@hackiftekhar And i was checked don't use becomFirstResponder(), just touch text field. The same situation was happend. Like this.

It seems that the problem occurs when I use UISheetPresentationController.

hackiftekhar commented 11 months ago

I'm unable to reproduce this issue like yours. It looks to be working perfectly fine for me. I need a demo project to debug it.

Once you attach a demo, please reopen the issue.