MoathOthman / MOLH

Localization helper for iOS apps mainly focusing on the LTR/RTL issue
MIT License
117 stars 36 forks source link

Images is not mirrored in first view controller in navigation #35

Closed bokhary3 closed 5 years ago

bokhary3 commented 5 years ago

Hi @MoathOthman, firstly thanks for this great library, There is a problem in the pod example, when change language to be arabic, image view in first ViewController not mirrored, if we set image view with tag = -1 in second view controller works fine, I see that if controller in navigation controller so it will loop on subviews in a navigation controller rather than a controller, I modified mirroringviewDidLoad method to handle. This is my code:

@objc func mirroringviewDidLoad() {
        mirroringviewDidLoad()
        if UIApplication.shared.userInterfaceLayoutDirection == .rightToLeft {
            if self is UINavigationController {
                if let viewController = (self as! UINavigationController).viewControllers.first {
                    loopThroughSubViewAndFlipTheImageIfItsNeeded(viewController.view.subviews)
                }
            } else {
                loopThroughSubViewAndFlipTheImageIfItsNeeded(self.view.subviews)
            }
        }
        // Do any additional setup after loading the view.
    }
MoathOthman commented 5 years ago

@bokhary3 I advise to reference all the images that needs to be mirrored as an iboutlet collectoin , and flip them in one place . you may add a collection in the superviewcontroller you may use and in view did load , loop through the images and flip them ,

so in the superviewcontroller or the viewcontroller

add @Iboutlet var imagesToFlip: [uiimageView]? and in view did load

imagesToFlip.forEach{$0.image = $0.image?.flipifneeded()} u need to import MOLH