2013-11-04 14 views
5

आईफोन सिम्युलेटर पर पोर्ट्रेट मोड में या डिवाइस पर लैंडस्केप में, यह सभी नेविगेशन बार बटन दिखाता है, लेकिन जब डिवाइस पर पोर्ट्रेट मोड में उपयोग किया जाता है, तो बटन नहीं होता है का प्रदर्शन किया। नीचे नेविगेशन बार की छवियां हैं।आईफोन नेविगेशन बार डिवाइस पर सभी बटन नहीं दिखाता

Simulator shows button

Device doesn't show button

डिवाइस मैं परीक्षण के लिए है एक iPhone आईओएस 6.1.3 (10B329) चल रहा 4S है। मैं जिस सिम्युलेटर का उपयोग कर रहा हूं वह संस्करण 7.0 (463.9.4) आईओएस 6.0/6.1 चल रहा है।

मैं संपादन मोड में खोज बटन को हटाने पर विचार कर रहा हूं, लेकिन मैं इस विकल्प को मोड के बावजूद उपयोगकर्ता को उपलब्ध रखना पसंद करूंगा।

कोई भी मदद या अंतर्दृष्टि की सराहना की जाती है, धन्यवाद।

संपादित करें: सही बटन शुरू में बनाया है और इसलिए तरह 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

मैं "कम विकल्प" विशेष रूप से पोर्ट्रेट मोड में iPhones के लिए विकल्प के साथ चला गया, क्योंकि मैं गायब बटन के लिए एक उचित समाधान नहीं मिल सकता है और वहाँ वास्तव में नहीं दिया ' पर्याप्त जगह नहीं है। लैंडस्केप और आईपैड पर, तीसरा बटन, _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

मैं पोर्ट्रेट मोड में विशेष रूप से iPhones के लिए "कम विकल्प" विकल्प के साथ गया क्योंकि मुझे गायब होने वाले बटन के लिए उचित समाधान नहीं मिला। टिप्पणी के लिए धन्यवाद। – DemonGyro

संबंधित मुद्दे