2013-11-04 4 views
5

iPhone SimulatorまたはLandscapeのデバイスのPortraitモードでは、すべてのナビゲーションバーボタンが表示されますが、デバイスのポートレートモードで使用すると、表示されます。以下は、ナビゲーションバーの画像です。iPhoneのナビゲーションバーにデバイスのすべてのボタンが表示されない

Simulator shows button

Device doesn't show button

私はテストのために持っているデバイスは、iOS 6.1.3(10B329)を実行しているiPhone 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

は私が消え、ボタンのための適切な解決策を見つけることができなかったので、ポートレートモードでは、特にiPhoneのための「レスオプション」オプションを使用して行って、そこに本当にwasn(当然、あなたの変数名は、最も可能性が高い異なります)十分なスペース。ランドスケープとiPadでは、3番目のボタン_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

は正直、好奇心のthats。おそらくそれが支配的なタイトルのいくつかの特性です。私の経験では、 "編集モード"中のオプションが少なくて済むようにするのが常にベストです。あなたがそのルートに行くことを決めた場合、ここに助けてくれる少しのコードがあります。 「

// 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

私は、ボタンが消えるのに適切な解決策を見つけることができなかったので、特にポートレートモードのiPhoneのための「オプションが少ない」オプションを使用しました。コメントありがとう。 – DemonGyro

関連する問題