Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
154 views
in Technique[技术] by (71.8m points)

ios - SWrevealviewcontroller : Switch slideout menu direction from left to right pragmatically

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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) {}
  1. 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";
        }
    

    }


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...