任何人都可以幫助我理解下面的函數有什麼問題嗎?通過按鈕調用某個功能
我對本機IOS dev相當陌生。
我想用本教程(http://www.appcoda.com/ios-programming-sidebar-navigation-menu/)在我們的應用程序中實現側面板。
所有這一切工作正常,足夠簡單 - 但我想通過觸發一個標準的按鈕,而不是在頭一個動態按鈕的顯示功能 - 以滿足我們的設計..
原始代碼如下 -
#import "SWRevealViewController.h"
// Change button color
_sidebarButton.tintColor = [UIColor colorWithWhite:0.96f alpha:0.2f];
// 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];
複製一個按鈕觸發的功能,添加以下的.h文件中 -
@property (weak, nonatomic) IBOutlet UIBarButtonItem *sidebarButton;
@property (weak, nonatomic) IBOutlet UIButton *revealLeftBtn;
- (IBAction)btnClickRevealL:(id)sender;
,並在我的.m文件以下
- (IBAction)btnClickRevealL:(id)sender {
[self.revealViewController];
[@selector(revealToggle:)];
}
我得到錯誤'懷疑標識符'的上述行 - 我不明白如何使用上述方法觸發的功能,而不是以上 - 任何人都可以幫助? 乾杯
以供參考,這是整個.m文件 -
#import "MainViewController.h"
#import "SWRevealViewController.h"
@interface MainViewController()
@end
@implementation MainViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"";
// Change button color
_sidebarButton.tintColor = [UIColor colorWithWhite:0.96f alpha:0.2f];
[self.navigationController.navigationBar setTranslucent:TRUE];
// Set the side bar button action. When it's tapped, it'll show up the sidebar.
// Set the gesture
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)btnClickRevealL:(id)sender {
[self.revealViewController];
[@selector(revealToggle:)];
}
@end
點相當於 - 感謝您的幫助@Antonio MG – Dancer