में आईफोन डिवाइस वर्तमान अभिविन्यास कृपया मेरी मदद करें। मैं तरीकों:ViewDidLoad
-(void) getCurrentOrientation{
UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
if(orientation == UIInterfaceOrientationPortrait){
NSLog(@"portrait");
} else if(orientation == UIInterfaceOrientationLandscapeRight) {
NSLog(@"LandscapeRight");
} else if(orientation == UIInterfaceOrientationLandscapeLeft) {
NSLog(@"LandscapeLeft");
}
}
लेकिन जब मैं इस getCurrentOrientation फोन फेंक viewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
[self getCurrentOrientation];
}
NSLog खाली है। क्या गलत है ? मैं भी
- (void)viewDidLoad
{
[super viewDidLoad];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait)) {
NSLog(@"portrait");
} else if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)
{
NSLog(@"LandscapeRight");
}
}
कोशिश लेकिन वह varint भी खाली।
मुझे यह जानने की ज़रूरत है कि कौन सा अभिविन्यास उपयोगकर्ता एपीपी लॉन्च करता है!
कृपया मुझे कोई सलाह दें।
धन्यवाद है। लेकिन जब मैं लैंडस्केप मोड में सिम्युलेटर पर चलता हूं, एनएसएलओएल आउटपुट पोर्ट्रेट। तो मुझे यकीन नहीं है कि यह वास्तविक डिवाइस –
पर काम को सही करेगा, कृपया अद्यतन उत्तर –
देखें, मैं प्रोजेक्ट - लक्ष्य - सारांश - समर्थित डिवाइस ओरिएंटेशन केवल लैंडस्केप में चयन करता हूं। लेकिन जब मैं आपके फ़ंक्शन Nslog आउटपुट पोर्ट्रेट के साथ एमुलेटर में ऐप चलाता हूं। और मुझे क्यों निर्भर नहीं होना चाहिए? मुझे बस यह जानने की जरूरत है कि किस अभिविन्यास में यूजर रन ऐप है। –