2013-12-17 11 views
8

नए आईओएस 7 UINavigationController में, विचारों के बीच स्विच करने के लिए एक स्वाइप इशारा है। क्या इशारा का पता लगाने या अवरोध करने का कोई तरीका है?आईओएस 7 uinavigationcontroller स्वाइप का पता लगाने के लिए कैसे?

+2

'मैं इसे अक्षम नहीं करूँगा'। आप इसे ध्वनि बनाते हैं जैसे आप "शरारती" –

+0

ऐसा इसलिए है क्योंकि मैंने "यूनाविगेशन कंट्रोलर में स्वाइप जेश्चर को अक्षम करने के तरीके" के बारे में एक समान विषय पढ़ा है। तो मैं स्पष्ट होना चाहता था ^^ – Steven

उत्तर

27

इंटरैक्टिव पॉप इशारा पहचानकर्ता UINavigationController की interactivePopGestureRecognizer संपत्ति के माध्यम से उजागर किया गया है। आप इशारा पहचानकर्ता का एक लक्ष्य के रूप में अपने स्वयं के नियंत्रक जोड़ सकते हैं और उचित प्रतिक्रिया कर सकते हैं:

@implementation MyViewController 

... 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    [self.navigationController.interactivePopGestureRecognizer addTarget:self 
                    action:@selector(handlePopGesture:)]; 
} 


- (void)handlePopGesture:(UIGestureRecognizer *)gesture 
{ 
    if (gesture.state == UIGestureRecognizerStateBegan) 
    { 
     // respond to beginning of pop gesture 
    } 
    // handle other gesture states, if desired 
} 

... 

@end 
+0

बिल्कुल सही! यह वही है जो मैं आपको धन्यवाद देना चाहता था। – Steven

7

यहाँ स्विफ्ट में Austin's answer है। चयनकर्ता बनाने के लिए this post का उपयोग करके, मुझे निम्नलिखित कार्य मिलते हैं।

override func viewDidLoad() { 
    super.viewDidLoad() 
    self.navigationController?.interactivePopGestureRecognizer?.addTarget(self, action:#selector(self.handlePopGesture)) 
} 

func handlePopGesture(gesture: UIGestureRecognizer) -> Void { 
    if gesture.state == UIGestureRecognizerState.Began { 
     // respond to beginning of pop gesture 
    } 
} 
+0

यह मेरे लिए प्रतिक्रिया नहीं दे रहा है ... मैं बस इशारा पहचान पर "हैलो" प्रिंट करना चाहता था –

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