简体   繁体   English

SWRevealViewController导航栏右键按钮项

[英]SWRevealViewController navigation bar right button item

I'm using the SWRevealViewController library to use on my app as a left slide menu; 我正在使用SWRevealViewController库在我的应用程序中用作左幻灯片菜单;

github link: SWRevealViewController github链接: SWRevealViewController

I've downloaded the following project example Appcoda project example and I've embedded the menu controller to a navigation controller so I can add items to the bar button , but I can't see the right bar button item that I've added (+ sign as example of ADD) 我已经下载了以下项目示例Appcoda项目示例 ,并将菜单控制器嵌入到导航控制器中,因此可以将内容添加到bar按钮,但是看不到添加的右边bar按钮项目( +符号作为添加示例)

I've tried to change the menu controller width, but everything went wrong , do you know a way to short the side menu width so I can see the right bar button item added? 我试图更改菜单控制器的宽度,但一切都出错了,您知道一种缩短侧面菜单宽度的方法,以便可以看到添加了右边栏按钮的项目吗?

In the following image the + sigh stays under the left (main) controller. 在下图中,+叹气停留在左侧(主)控制器下方。

I'm new to this kind of things :) 我是这种东西的新手:)

Thanks in advance 提前致谢

例

Do something like the code below and set x value according to your position in cgrectmake 做类似下面的代码,并根据您在cgrectmake的位置设置x值

 UIButton *PlusBtn = [[UIButton alloc] initWithFrame:CGRectMake(0,0,44,44)];
    PlusBtn.tag = 654;
    [PlusBtn setImageEdgeInsets:UIEdgeInsetsMake(14, 14, 16, 16)];
    [PlusBtn setImage:[UIImage imageNamed:@"menu_icon1.png"] forState:UIControlStateNormal];
    [PlusBtn addTarget:self action:@selector(ShowLeft) forControlEvents:UIControlEventTouchUpInside];
    PlusBtn.enabled = NO;

    [self.navigationController.navigationBar addSubview:PlusBtn];

In Storyboard you set the UiViewController's size to be freeform instead of Inferred under Attributes Inspector, then under Size Inspector you set the width of the ViewController according the the size that the button shows. 在情节提要中,您可以将UiViewController的大小设置为自由形式,而不是在“属性”检查器下“推断”,然后在“大小”检查器下,根据按钮显示的大小来设置ViewController的宽度。 在此处输入图片说明 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM