Iphone UIStoryboard中的UIBarButtonItem显示动作方法中的错误
在UIstoryboard中添加了uibarbuttonim,并声明了uibarbuttonim的操作方法 当为action方法编写代码时,它会在这一行显示错误Iphone UIStoryboard中的UIBarButtonItem显示动作方法中的错误,iphone,objective-c,ios6,Iphone,Objective C,Ios6,在UIstoryboard中添加了uibarbuttonim,并声明了uibarbuttonim的操作方法 当为action方法编写代码时,它会在这一行显示错误 [_bookmarkbtn setBookmarkState:NO]; 在这条线上 [_bookmarkbtn setBookmarkState:YES]; 在下面的uibarbuttonite操作方法中 uibarbuttonitem没有可见的@interface声明选择器“setBookmarkState” - (IBActio
[_bookmarkbtn setBookmarkState:NO];
在这条线上
[_bookmarkbtn setBookmarkState:YES];
在下面的uibarbuttonite操作方法中
uibarbuttonitem没有可见的@interface声明选择器“setBookmarkState”
- (IBAction)bookmarkAction:(id)sender {
currentIndex = [modelArray indexOfObject:contentViewController.page];
if ([contentViewController.bookmarks containsIndex:currentIndex]) // Remove bookmark
{
[_bookmarkbtn setBookmarkState:NO]; [contentViewController.bookmarks removeIndex:currentIndex];
}
else // Add the bookmarked page index to the bookmarks set
{
[_bookmarkbtn setBookmarkState:YES]; [contentViewController.bookmarks addIndex:currentIndex];
}
}
使用故事板时,我如何为此发出target:self action:@selector语句
这可能对你有帮助。试试看。谢谢,但那没用。而是通过这样写来修复它_bookmarkbtn.enabled=NO;和_bookmarkbtn.enabled=是;检查在接口方法setBookmarkState:(或属性bookmarkState)中是否有类UIBarButtonim。我在UIBarButtonim的文档中找不到任何名为bookmarkState的属性。。。
-(IBAction) btnOpenImage_Clicked:(id)sender{
//1. IF buttons are UIBarButtonItem then use bellow code
// This bellow line for Change the action(Target)
[rightNavButton1 setAction:@selector(rightNavButton2_Clicked)];
//This bellow line For Change the Title
[rightNavButton1 setTitle:@"rightNavButton2_Clicked"];
//OR 2. IF buttons are UIButton then use bellow code
// This bellow line for Change the action(Target)
[rightNavButton1 addTarget:self action:@selector(rightNavButton2_Clicked) forControlEvents:UIControlEventTouchUpInside];
//This bellow line For Change the Title
[rightNavButton1 setTitle: @"rightNavButton2" forState: UIControlStateNormal];
}