实用地从左到右切换滑出菜单的方向

实用地从左到右切换滑出菜单的方向

本文介绍了SWrevealviewcontroller:实用地从左到右切换滑出菜单的方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用两种语言(英语和阿拉伯语)的应用程序,我已经使用左侧的"SWrevealviewcontroller" lib实现了滑出菜单,我想将滑出菜单切换到右侧,在语言更改(阿拉伯语)的左侧,然后再切换回右侧,从左侧切换为英语.我们如何存档?谢谢

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

推荐答案

实际上,您必须获取应用程序语言,例如您拥有Helper类并放置静态方法以获取应用程序的语言.

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

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

更新:

1.将segue标识符更改为"sw_right".2.现在在SWRevealViewController中在loadStoryboardControllers方法中先发表评论,然后尝试捕获这样的

1.Change the segue identifier to "sw_right".2. NOW in SWRevealViewControllerin loadStoryboardControllers mehtodcomment first try catch like this

-//        @try
-//        {
-//            [self performSegueWithIdentifier:SWSegueRightIdentifier sender:nil];
-//        }
-//        @catch(NSException *exception) {}
  1. 在执行方法中添加此代码

  1. in perform method add this code

NSString * identifier = self.identifier;

NSString *identifier = self.identifier;

if (![identifier isEqualToString:SWSegueFrontIdentifier]) {
    if ([[H getApplicationLanguage]isEqualToString:ARABIC_LANGUAGE]) {
        identifier = @"sw_right";
    }else{
        identifier = @"sw_rear";
    }

}

这篇关于SWrevealviewcontroller:实用地从左到右切换滑出菜单的方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 22:14