我正在尝试在我的应用程序中创建一个弹出菜单,就像 facebook 应用程序所使用的那样。
我找到了这个非常好的教程,并在他们的示例中使用了它。 http://www.appcoda.com/ios-programming-sidebar-navigation-menu/
在他们的示例中,他们使用导航栏上的导航栏项目作为激活和停用弹出菜单的按钮。
在我当前的项目中,我不想使用导航栏,而更愿意只使用一个按钮来激活弹出菜单。
不过,当涉及到以下代码时,我不知道该怎么做。
// Set the side bar button action. When it's tapped, it'll show up the sidebar.
_sidebarButton.target = self.revealViewController;
_sidebarButton.action = @selector(revealToggle:);
// Set the gesture
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
我无法将操作和目标设置为普通按钮。
有什么简单的方法可以解决这个问题吗?
谢谢
最佳答案
您可以设置一个 UIButton 来调用这样的选择器:
[button addTarget:self
action:@selector(revealToggle:)
forControlEvents:UIControlEventTouchUpInside];
关于iphone - 创建没有导航栏按钮的弹出菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18045709/