我可以正确调用“toggleMasterVisible”方法作为Button动作,但我想像这样扩展方法。
(In Button action. It works)
.h
@interface DetailViewController : UIViewController <UISplitViewControllerDelegate>
@end
.m
UIBarButtonItem *listBarButtonItem = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:@"list.png"]
style:UIBarButtonItemStyleBordered
target:self.splitViewController
action:@selector(toggleMasterVisible:)];
(I want to expand the method)
.m
UIBarButtonItem *listBarButtonItem = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:@"list.png"]
style:UIBarButtonItemStyleBordered
target:self
action:@selector(toggleMasterVisibleIfCondtionIsOK:)];
-(void)toggleMasterVisibleIfCondtionIsOK
{
if(isConditionOK){
[self.splitViewController toggleMasterVisible];
}
}
但是,我收到一个错误,“UISplitViewController'声明没有可见的@interface”。方法在哪里定义?我在参考文献(http://developer.apple.com/library/ios/#documentation/uikit/reference/UISplitViewController_class/Reference/Reference.html)上找不到方法,如何调用该方法?任何帮助将不胜感激。
答案 0 :(得分:7)
我得到了它:
[self.splitViewController performSelector:@selector(toggleMasterVisible:)];
答案 1 :(得分:0)
只需在anonymous category中对其进行定义,如下所示:
@interface UISplitViewController()
- (void)toggleMasterVisible:(id)sender;
@end