2012-09-20 5 views
0

프로그래밍 방식으로 일부 바 버튼 항목을 만들지 만 첫 번째 버튼의 탭 선택기가 호출되지 않습니다. 나는 지금 내있는 viewDidLoad에서 다음 코드를 가지고 :UIBarButtonItem 응답이 없습니다

[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]; 

지금까지 발견 한 무슨 난 후 첫 번째 항목의 선택에 라벨의 선택 (도구 모음에서 두 번째 항목)을 설정하는 경우 첫 번째 항목 선택기가 호출됩니다.

아이디어가 있으십니까?

답변

0

barbutton을 할당했지만 barButton에 frame을 설정하지 않았습니다.

할당 후 barButton에 대한 프레임을 설정합니다.

btnSpinner.frame=CGRectMake(10,10,70,40); 
+0

나는이 문제를 직접 해결했다. 적어도 말하기에는 이상한 문제였습니다. 두 번째 요소의 텍스트가 더 길면 첫 번째 Barbutton에 대한 작업이 호출되지 않는 것으로 나타났습니다. 텍스트를 짧게 만든 후에는 제대로 작동하기 시작했습니다. 그래도 입력 주셔서 감사합니다. – userx

관련 문제