SWrevealviewcontroller : Switch slideout menu direction from left to right pragmatically

那年仲夏 提交于 2019-12-13 09:02:36

问题


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


回答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) {}
  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";
        }
    

    }



来源:https://stackoverflow.com/questions/40327821/swrevealviewcontroller-switch-slideout-menu-direction-from-left-to-right-pragm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!