我正在以编程方式创建一些barbutton项目,但是没有调用第一个按钮上的选择器。我现在在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];
到目前为止,我发现如果我将Label的选择器(工具栏中的第二项)设置为第一项的选择器,则调用第一项选择器。
有什么想法吗?
答案 0 :(得分:0)
您分配了条形按钮但没有为条形按钮设置框架。
为barButton分配设置框架后。
btnSpinner.frame=CGRectMake(10,10,70,40);