Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UITableview keyboard issue #1

Open
iCodist opened this issue Mar 31, 2020 · 3 comments
Open

UITableview keyboard issue #1

iCodist opened this issue Mar 31, 2020 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@iCodist
Copy link

iCodist commented Mar 31, 2020

I have a UITextfield in a table view cell, table view will have a wrong content offset after this field become first responder, if you toggle iOS's user interface style.

The code causing the problem:

public class ThemeContainer {
    public static var windowsContainer: WindowsContainer = UIApplication.shared
    public static var currentTheme: ThemeProtocol! {
        didSet {
            if let old = oldValue {
                old.appearanceRules.revert()
            }

            windowsContainer.windows.forEach { window in
                window.applyTheme(currentTheme)
            }
        }
    }
}
@gringoireDM gringoireDM self-assigned this Mar 31, 2020
@gringoireDM
Copy link
Owner

What do you mean by "if you toggle iOS's user interface style"?
The code you posted is what makes possible the switch between themes.

Can you provide a sample project with the issue please?

@gringoireDM gringoireDM added the question Further information is requested label Mar 31, 2020
@iCodist
Copy link
Author

iCodist commented Mar 31, 2020

The problem will arise after I tap the dark mode button in iOS control center.

I solved the problem in this way:

public class ThemeContainer {
    public static var windowsContainer: WindowsContainer = UIApplication.shared
    public static var currentTheme: ThemeProtocol! {
        didSet {
            if let old = oldValue {
                old.appearanceRules.revert()
            }

            windowsContainer.windows.forEach { window in
                if window is ThemedWindow {
                    window.applyTheme(currentTheme)
                }
            }
        }
    }
}

This lib saved me a lot of time, thanks a lot!

@gringoireDM
Copy link
Owner

While this fix might apply to your specific case it is not a general purpose solution, because the way normal windows won't have applied theme.

If you could share a sample project that reproduces the issue I might be able to provide a better future proof solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants