I working on app which have two language (English and Arabic) , I have implement slide out menu using "SWrevealviewcontroller" lib for left side, I want to switch slide out menu to right side form left side on language change (Arabic) and switch back again to right side to left for english language. How can we archive it? Thanks
Asked
Active
Viewed 1,016 times
-1
-
1Put some of your code here – Firefog Oct 30 '16 at 10:17
1 Answers
1
Actually you must to get the application language, let's say you have Helper class and put static method to get the language of the application.
Helper.m
+(void)getApplicationLanguage{
//return application language
}
ViewController.m
-(IBAction)menuButtonClicked:(id)sender{
if ([[Helper getApplicationLanguage] isEqualToString:@"Arabic"]){
//slide from right
}else{
//slide from left
}
}
I did this on my applications, Hope this works for you
UPDATE:
1.Change the segue identifier to "sw_right". 2. NOW in SWRevealViewController in loadStoryboardControllers mehtod comment first try catch like this
-// @try
-// {
-// [self performSegueWithIdentifier:SWSegueRightIdentifier sender:nil];
-// }
-// @catch(NSException *exception) {}
in perform method add this code
NSString *identifier = self.identifier;
if (![identifier isEqualToString:SWSegueFrontIdentifier]) { if ([[H getApplicationLanguage]isEqualToString:ARABIC_LANGUAGE]) { identifier = @"sw_right"; }else{ identifier = @"sw_rear"; }
}

Ali Omari
- 371
- 3
- 11
-
Didn't worked for me, according to your way, I did like this : override func viewDidLoad() { if self.revealViewController() != nil { menuBtn.target = self.revealViewController() let currentLang = userDefaultData.valueForKey("lang") as! String if currentLang == "en" { menuBtn.action = #selector(SWRevealViewController.revealToggle(_:)) }else { menuBtn.action = #selector(SWRevealViewController.rightRevealToggle(_:)) }self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer()) } } – Nitin Solanki Oct 30 '16 at 11:24
-
Its not working because of I have set segue identifier to “sw_rear” from storyboard. If i know how to change identifier "sw_rear" to "sw_right" from coding then my problem will solve. – Nitin Solanki Oct 30 '16 at 11:25
-
how to change identifier programically. i need to use both sw_rear for english language and sw_right for arabic. – Nitin Solanki Oct 30 '16 at 12:03
-
@NitinSolanki because i can't make the text as i want in stackoverflow editor the text appears like that, but if you want i can send you the update SWRevealViewController.m class to copy it in your project and it will works perfectly. – Ali Omari Oct 30 '16 at 12:48
-
i am working with swift and storing and fetching language key using NSuserDefaultData. plz send me updated file to my email : nitinsolanki4@gmail.com – Nitin Solanki Oct 30 '16 at 13:52
-
@NitinSolanki Have you get your answer to set menubar right or left as per language – Bhavin Ramani Dec 31 '16 at 11:49
-
@AliOmari Can you tell me please how to manage sidebar to right or left as per language selection. – Bhavin Ramani Dec 31 '16 at 11:54
-
@BhavinRamani i'm answering that question in my answer, you can read my answer carefully and i'm sure that it will you for you. – Ali Omari Dec 31 '16 at 20:05
-