2013-11-04 1 views
5

iPhone Simulator 또는 가로보기의 세로 모드에서 모든 탐색 모음 단추가 표시되지만 세로보기 모드에서 장치를 사용하면 단추가 표시되지 않습니다. 표시됩니다. 아래는 탐색 바의 이미지입니다. iPhone 탐색 모음에 장치의 모든 단추가 표시되지 않습니다.

Simulator shows button

Device doesn't show button

내가 테스트를 위해이 장치

는 아이폰 OS 6.1.3 (10B329)를 실행 아이폰 4S입니다. 내가 사용중인 시뮬레이터는 iOS 6.0/6.1을 실행하는 버전 7.0 (463.9.4)입니다.

편집 모드에서 검색 버튼을 제거하는 것을 고려하고 있지만 모드에 관계없이이 옵션을 계속 사용할 수 있습니다.

도움이나 의견을 보내 주시면 감사하겠습니다.

편집 : 처음 생성 등처럼의 ViewController에 대한 viewDidLoad:에 추가 오른쪽 버튼 :

_deleteBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:@selector(deleteRows:)]; 
_deleteBarButtonItem.tintColor = [UIColor redColor]; 

_searchBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(searchButtonClicked:)]; 

self.navigationItem.rightBarButtonItems = @[_searchBarButtonItem, self.editButtonItem]; 

그리고 편집 모드를 입력 할 때 :

- (void)setEditing:(BOOL)editing animated:(BOOL)animated 
{ 
    [super setEditing:editing animated:animated]; 

    if (self.tableView.isEditing) { 
     // turn off editing 
     _deleteBarButtonItem.enabled = NO; 
     [self.tableView setEditing:NO animated:animated]; 
     [self.editButtonItem setStyle:UIBarButtonItemStylePlain]; 
     self.navigationItem.rightBarButtonItems = @[_searchBarButtonItem, self.editButtonItem]; 
    } else { 
     // turn on editing 
     [self.tableView setEditing:YES animated:animated]; 
     [self.editButtonItem setStyle:UIBarButtonItemStyleDone]; 
     self.navigationItem.rightBarButtonItems = @[_searchBarButtonItem, _deleteBarButtonItem, self.editButtonItem]; 
    } 
} 
+0

버튼이 막대에 어떻게 추가됩니까? – nhgrif

+0

위의 편집을 확인하십시오. – DemonGyro

답변

0

나는 내가 사라지는 단추에 대한 적절한 해결책을 찾을 수 없기 때문에 세로 모드에서 특히 아이폰에 대해 "적은 옵션"옵션으로 가서 거기에 정말 얻지 못한 (자연적으로, 당신의 변수 이름은 대부분 다릅니다) 충분한 공간. 가로 및 iPad에서는 세 번째 버튼 _searchBarButtonItem이 표시 될 수 있으므로 표시됩니다.

다음은 원하는 동작을 위해 변경 한 내용입니다. 나는이 사람들이 유용하다고 생각하기를 바랍니다.

-(void) viewDidLoad { 
    ... 
    self.navigationItem.rightBarButtonItems = @[_searchBarButtonItem, self.editButtonItem]; 
} 

- (void) viewWillAppear:(BOOL)animated 
{  
    [super viewWillAppear:animated]; 

    if (self.playerTableView.isEditing && !IS_IPAD) 
    { 
     if (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])) 
     { 
      self.navigationItem.rightBarButtonItems = @[_deleteBarButtonItem, self.editButtonItem]; 
     } 
     else 
     { 
      self.navigationItem.rightBarButtonItems = @[_searchBarButtonItem, _deleteBarButtonItem, self.editButtonItem]; 
     } 
    } 
} 

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
    [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration]; 

    if (self.playerTableView.isEditing && !IS_IPAD) 
    { 
     if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) 
     { 
      self.navigationItem.rightBarButtonItems = @[_deleteBarButtonItem, self.editButtonItem]; 
     } 
     else 
     { 
      self.navigationItem.rightBarButtonItems = @[_searchBarButtonItem, _deleteBarButtonItem, self.editButtonItem]; 
     } 
    } 
} 

- (void)setEditing:(BOOL)editing animated:(BOOL)animated 
{ 
    [super setEditing:editing animated:animated]; 
    ...  
    if (self.playerTableView.isEditing) { 
     ... 
     self.navigationItem.rightBarButtonItems = @[_filterBarButtonItem, self.editButtonItem]; 
    } else { 
     ... 
     if (!IS_IPAD && UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])) 
     { 
      self.navigationItem.rightBarButtonItems = @[_deleteBarButtonItem, self.editButtonItem]; 
     } 
     else 
     { 
      self.navigationItem.rightBarButtonItems = @[_searchBarButtonItem, _deleteBarButtonItem, self.editButtonItem]; 
     } 
    } 
} 
1

솔직히 호기심 이잖아. 아마도 그것은 타이틀을 지배하게 만드는 속성 일 것입니다. 내 경험에 비추어 볼 때, "편집 모드"동안 옵션을 줄이는 것이 가장 좋습니다. 해당 경로로 이동하기로 결정했다면 도움이 될만한 코드가 있습니다. '

// Get the reference to the current toolbar buttons 
NSMutableArray *toolbarButtons = [self.toolbarItems mutableCopy]; 

if (editing) { 
    // This is how you remove the button from the toolbar and animate it 
    [toolbarButtons removeObject:self.myButton]; 
    [self setToolbarItems:toolbarButtons animated:YES]; 
} else { 
    // This is how you add the button to the toolbar and animate it 
    if (![toolbarButtons containsObject:self.myButton]) { 
     // The following line adds the object to the end of the array. 
     // If you want to add the button somewhere else, use the `insertObject:atIndex:` 
     // method instead of the `addObject` method. 
     [toolbarButtons addObject:self.myButton]; 
     [self setToolbarItems:toolbarButtons animated:YES]; 
    } 
} 
+0

사라지는 버튼에 대한 적절한 해결책을 찾을 수 없었기 때문에 초상화 모드의 iPhones에 대해 "적은 옵션"옵션을 사용했습니다. 댓글 주셔서 감사합니다. – DemonGyro

관련 문제