मैं प्रत्येक पृष्ठ के लिए UITabBarController और UIViewControllers के आधार पर एक आईफोन एप्लिकेशन पर काम कर रहा हूं। अनुप्रयोग, केवल पोर्ट्रेट मोड में चलाने के लिए की जरूरत है ताकि हर दृश्य नियंत्रक + एप्लिकेशन प्रतिनिधि कोड की इस पंक्ति के साथ चला जाता:मैन्युअल रूप से परिदृश्य में रोटेशन का पता लगाने
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
वहाँ एक दृश्य नियंत्रक जब iPhone rotaed वह जगह है जहाँ मैं एक UIImageView पॉप अप करना चाहते हैं परिदृश्य के लिए। छवि का डिज़ाइन परिदृश्य दिखता है, हालांकि चौड़ाई और ऊंचाई 320x460 (इसलिए इसका चित्र) है।
मैं इस प्रकार के घूर्णन को मैन्युअल रूप से कैसे पहचान सकता/सकती हूं, बस इस विशिष्ट दृश्य नियंत्रक में, पूरे दृश्य पर ऑटो रोटेशन के साथ?
थॉमस
अद्यतन:
धन्यवाद!
मैं viewDidLoad में इस श्रोता कहा:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:)name:UIDeviceOrientationDidChangeNotification object:nil];
didRotate इस तरह दिखता है:
- (void) didRotate:(NSNotification *)notification
{
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation == UIDeviceOrientationLandscapeLeft)
{
//your code here
}
}
धन्यवाद आग नहीं होगा! मैंने इस श्रोता को दृश्य में जोड़ा हैडलोड: [[NSNotificationCenter defaultCenter] addObserver: स्वयं चयनकर्ता: @ चयनकर्ता (didRotate:) नाम: UIDeviceOrientationDidChangeNotification ऑब्जेक्ट: nil]; didRotate इस तरह दिखता है: - (शून्य) didRotate: (NSNotification *) अधिसूचना {\t \t UIDeviceOrientation उन्मुखीकरण = [[UIDevice currentDevice] उन्मुखीकरण]; \t \t अगर (उन्मुखीकरण == UIDeviceOrientationLandscapeLeft) \t { \t \t // यहाँ कोड \t} } –
माइनर में सुधार, अपने स्ट्रिंग मान के बजाय लगातार UIDeviceOrientationDidChangeNotification का उपयोग (जो @ "UIDeviceOrientationDidChangeNotification") –
घटना के लिए श्रोता के रूप में खुद को पंजीकरण रद्द करने के लिए मत भूलना ... – aroth