2011-04-27 16 views
8

में कॉल नहीं किया जा रहा है, मेरे पास UITabBarController है और मैंने अपनी प्रतिनिधि विधि didSelectViewController स्थापित की है, क्योंकि मुझे चयनित टैब की अनुक्रमणिका में रूचि है।didSelectViewController को "अधिक" अनुभाग

हालांकि, मैंने देखा didSelectViewController विधि उपयोगकर्ता "अधिक" अनुभाग में है जब (जब वहाँ अधिक टैब से tabbar में दिखाया जा सकता है) कहा जाता है नहीं प्राप्त करता है कि:

The problematic section

क्या मेरे द्वारा स्वचालित रूप से बनाए जा रहे तालिका से उपयोगकर्ता द्वारा चुने गए आइटमों के बारे में अधिसूचित होने का कोई तरीका है?

+0

मैंने इसे भी समझने की कोशिश की है। जब तक वे अधिक टैप करते हैं, तब तक मुझे यह पता चल सकता है कि वे अधिक देखने वाले नियंत्रक से कौन से व्यू कंट्रोलर का चयन करते हैं, गैर-सार्वजनिक एपीआई कॉल का उपयोग करने की आवश्यकता है। –

+0

@ ग्रेग, मेरा उत्तर देखें। – Shade

उत्तर

8

मुझे मिला कि मुझे this question में क्या चाहिए था।

मूल रूप से आप एक UITabBarControllerDelegateऔर कि अधिक टैब के अंदर प्रदर्शित किया जाता है नेविगेशन नियंत्रक के लिए एक UINavigationControllerDelegate की स्थापना की। इसके बाद आप यह पता लगाते हैं कि उपयोगकर्ता दृश्यमान टैब में से एक या "अधिक" टैब को स्पर्श करता है या नहीं।

संपादित

इसके अलावा

, सीधे तालिका कि "अधिक" नेविगेशन नियंत्रक के भीतर दिखाई दे रहा है हेरफेर करने के लिए, आप एक "मैन-इन-द-मिडल" तालिका दृश्य प्रतिनिधि, कि करने के लिए कॉल को बीच में रोक सेट कर सकते हैं मूल प्रतिनिधि। अंदर didSelectViewController नीचे से कोड देखें:

if (viewController == tabBarController.moreNavigationController && tabBarController.moreNavigationController.delegate == nil) { 
    // here we replace the "More" tab table delegate with our own implementation 
    // this allows us to replace viewControllers seamlessly 

    UITableView *view = (UITableView *)self.tabBarController.moreNavigationController.topViewController.view; 
    self.originalDelegate = view.delegate; 
    view.delegate = self; 
} 

उसके बाद, आप जो कुछ भी आप, प्रतिनिधि तरीकों के अंदर की तरह है जब तक कि आप अन्य प्रतिनिधि में एक ही तरीके का फोन करने के लिए स्वतंत्र हैं (मैं वास्तव में जो तरीकों की जाँच मूल प्रतिनिधि उत्तर देता है, और लागू किया गया एकमात्र प्रतिनिधि तरीका didSelectRow:forIndexPath: है)। नीचे एक उदाहरण देखें:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    // this is the delegate for the "More" tab table 
    // it intercepts any touches and replaces the selected view controller if needed 
    // then, it calls the original delegate to preserve the behavior of the "More" tab 

    // do whatever here 
    // and call the original delegate afterwards 
    [self.originalDelegate tableView: tableView didSelectRowAtIndexPath: indexPath]; 
} 
+0

क्या आपने एनएसएलओजी दोनों प्रतिनिधियों को यह देखने के लिए कोशिश की है कि यह अलग है या नहीं? ऐसा लगता है कि यह वही है। –

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