我试图用SWreveal ViewController实现吧按钮,而不是实现滑块按钮“打开”对于所有的视图。我做了一个基类BaseController,从那里我继承了我希望有滑块但我的滑块的viewcontroller下面的代码适用于平移手势但代码2不适用于按钮。可以有人告诉我为什么?
代码1 :(工作代码)
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
...
String name = req.getParameter("name");
System.out.println("name: " + name);
...
}
Code2 :(不工作)
self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(title: "Sider", style: .done, target: self, action: nil ) self.navigationItem.leftBarButtonItem?.target = self.revealViewController() self.navigationItem.leftBarButtonItem?.action = Selector("revealToggle:")
Code1有效,但Code2不起作用有人可以告诉我原因。
答案 0 :(得分:0)
在 Code2 检查Selector("revealToggle:")
不是您的类方法,因此您必须在code2中选择target: SWrevealViewController
您可以编写如下代码:
self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(title: "Sider", style: .done, target: self.revealViewController(), action: Selector("revealToggle:") )