我正在以编程方式创建一些条形按钮项目,但是没有调用第一个按钮的选择器。我的 viewDidLoad 现在有以下代码:
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// self.navigationItem.leftBarButtonItem = self.editButtonItem;
_defaultBarColor = self.navigationController.navigationBar.tintColor;
[self loadPreferences];
self.spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
self.btnSpinner = [[UIBarButtonItem alloc] initWithCustomView:self.spinner];
self.btnRefresh = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refreshPressed:)];
self.lblLastUpdate = [[UIBarButtonItem alloc] initWithTitle:@" " style:UIBarButtonItemStylePlain target:nil action:nil];
[self.lblLastUpdate setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont boldSystemFontOfSize:13], UITextAttributeFont,nil] forState:UIControlStateNormal];
self.flexibleSpace = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
self.toolbarItems = [NSArray arrayWithObjects:self.btnRefresh,self.flexibleSpace,self.lblLastUpdate,self.flexibleSpace, nil];
self.detailViewController = (DetailViewController *)[[self.splitViewController.viewControllers lastObject] topViewController];
[self loadData];
到目前为止,我发现如果我将标签(工具栏中的第二项)的选择器设置为第一项的选择器,那么第一个项目选择器会被调用。
有任何想法吗 ?