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

Change SideBarMenu from left to right #676

Open
ibhavin opened this issue Jan 25, 2017 · 24 comments
Open

Change SideBarMenu from left to right #676

ibhavin opened this issue Jan 25, 2017 · 24 comments

Comments

@ibhavin
Copy link

ibhavin commented Jan 25, 2017

I want to change "SidebarMenu" from left to right when Arabic language is selected in my app. In my app when I select Arabic language then barbutton(menuButton) is move to right side. So, I want to open "SideBarMenu" from right side. In english language it should open from left side as usual.

Here is the code in ViewController:

override func viewDidLoad() {
super.viewDidLoad()

    let currentLanguageCode = LanguageManager.currentLanguageCode()
    if currentLanguageCode == "ar" {
        // I want to show "SideBarMenu" from right side
    } else {
       // I want to show "SideBarMenu" from left side 
    }

    if self.revealViewController() != nil {
        menuButton.target = self.revealViewController()
        menuButton.action = #selector(SWRevealViewController.revealToggle(_:))
        self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
    }
}

I have tried to set rightViewController but its not working.
revealController?.setRight(rearController, animated: true)

@iDevelopper
Copy link

I wrote this for another issue:

SWArabic 2.zip

@ozamihir1990
Copy link

ozamihir1990 commented Jul 20, 2018

@iDevelopper have you changed anything in storyboard in above demo? I am using objective c and I want to implement for Arabic. So could you help to implement RTL in revealviewcontroller?

My source code

SWRevealViewController *revealViewController = self.revealViewController;
    if ( revealViewController )
    {
        if ([Util isDeviceLanguageRTL]) {
            [self.btnMenu setTarget:self.revealViewController];
            [self.btnMenu setAction: @selector(revealToggle:)];
            [self.view addGestureRecognizer:self.revealViewController.tapGestureRecognizer];
            self.revealViewController.rearViewRevealWidth = self.view.frame.size.width - 100;
            
            revealViewController.rightViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"RearTableViewController"];
            revealViewController.rearViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"VC"];
        } else {
            [self.btnMenu setTarget: self.revealViewController];
            [self.btnMenu setAction: @selector( revealToggle: )];
            [self.view addGestureRecognizer:self.revealViewController.tapGestureRecognizer];
            self.revealViewController.rearViewRevealWidth = self.view.frame.size.width - 100;
        }
    }

@iDevelopper
Copy link

@ozamihir1990 , no change in storyboard, only the code in FrontViewController. What's your problem?

@ozamihir1990
Copy link

@iDevelopper segue is not working which I implement in my RearTableViewController. It works in English but when I change to Arabic If I click on any cell it's not working.
I used segue in my storyboard to present my view.

Please see my storyboard screenshots :
screen shot 2018-07-20 at 6 27 42 pm
screen shot 2018-07-20 at 6 27 18 pm

@iDevelopper
Copy link

First when you are RTL the btnMenu action should be rightRevealToggle and not revealToggle.

And in the sample I added a push segue which works well when RTL or LTR:

SWArabic 2.zip

Could you let me know if this sample works for you?

@ozamihir1990
Copy link

@iDevelopper sorry for late replay,
I can see the menus in Right Side, but when I click on any menu item it's not pushed to relevant screen. For example, If I pressed on Item 0 or Item 1 nothing happens (I know you didn't add any viewController but I added segue. Please see my above screenshots).

@iDevelopper
Copy link

As I said, in the above sample I added a segue and when item 0 or item 1 are clicked the front view is pushed. It is not the case for you?

@ozamihir1990
Copy link

ozamihir1990 commented Jul 23, 2018

I think there is some miscommunication, in your example when I pressed on item 0 or item 1 nothing happens because you didn't add any segue in item 0 or item 1, but I added my segue in cell pressed in storyboard(it works in English but when I change to Arabic it doesn't work. )

@iDevelopper
Copy link

Perhaps you did not get the last example, however I added two segues now. One for item 0 and one for item 1.

Video:
2018-07-23_09-09-02.mp4.zip
Sample project:
SWArabic 2 2.zip

@ozamihir1990
Copy link

ozamihir1990 commented Jul 23, 2018

Your app is crashing when I use Arabic, you didn't add any segue in Arabic storyboard.
screen shot 2018-07-23 at 1 03 13 pm

@ozamihir1990
Copy link

I am using a single storyboard, for other languages, I am using Main.strings.

@iDevelopper
Copy link

No only in the main storyboard, it should be sufficient as the project is localised. Why the app does not crash here?

@iDevelopper
Copy link

However I removed the others storyboard now. I have one storyboard (base) and three .strings.

SWArabic 2 3.zip

@ozamihir1990
Copy link

ozamihir1990 commented Jul 23, 2018

I think it's your storyboard issue. you didn't add 2 cell in Arabic.
Crash log :

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier Cell0 - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'

Are you checking in same code which you provided?

@iDevelopper
Copy link

There are two cells for each language, only one storyboard... No issues here. I am using Xcode 10.0 beta 3.

@ozamihir1990
Copy link

I am using Xcode 9.3, So I am not sure but it's using Arabic storyboard in Xcode 9

@ozamihir1990
Copy link

ozamihir1990 commented Jul 23, 2018

Please see the uploaded video in xcode 9.3
Screen Recording.zip

@ozamihir1990
Copy link

Hello, @iDevelopper any suggestions for my issue?

@iDevelopper
Copy link

Hi @ozamihir1990 , I will test with Xcode 9.4.1 now.

@iDevelopper
Copy link

Works like a charme. Xcode 9.4.1 - Simulator iPhone 6s RTL language arabic. What can I do?

@ozamihir1990
Copy link

ok, @iDevelopper let me check maybe I did some minor mistake in the code.
Thanks for your support.

@iDevelopper
Copy link

But is my sample works without change anything in it?

@iDevelopper
Copy link

SWArabic 2.zip

@ozamihir1990
Copy link

ozamihir1990 commented Jul 30, 2018

@iDevelopper Sorry for late replay, I got the solution. Actually, I was using common array for cell identifier,display cell label and image name. and I used NSLocalizedString for that array. Then cell identifiers also changes when I change to Arabic.

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

No branches or pull requests

3 participants