पृष्ठभूमि & उद्देश्य: मेरे पास UISplitViewController आधारित आईपैड ऐप है - अब तक यह 4 ओरिएंटेशन का समर्थन करता है लेकिन अब मैं इसे केवल लैंडस्केप पर लॉक करना चाहता हूं। मैंने केवल लैंडस्केप मोड का समर्थन करने के लिए बाएं व्यू कंट्रोलर के shouldAutorotateToInterfaceOrientation
को बदल दिया, लेकिन यह viewWillAppear
को कॉल करने से रोकता है।ViewWillAppear UISplitViewController
विवरण: मेरे iPad के दृश्य नियंत्रक नीचे व्यवस्थित होते हैं:
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
HostManagerViewController *hvc = [[[HostManagerViewController alloc]
initWithNibName:nil bundle:nil] autorelease];
self.detailViewController = [[[DetailViewController alloc]
initWithNibName:nil bundle:nil] autorelease];
UINavigationController *rootNav = [[[UINavigationController alloc]
initWithRootViewController:hvc] autorelease];
UISplitViewController *splitVC= [[[UISplitViewController alloc] init] autorelease];
[splitVC setViewControllers:[NSArray arrayWithObjects:rootNav,
detailViewController, nil]];
splitVC.delegate = detailViewController;
[window addSubview:splitVC.view];
[window setRootViewController:splitVC];
return YES;
}
viewWillAppear
कहा जाता हो जाता है जब दोनों DetailViewController.m
और HostManagerViewController.m
window
`-- splitVC (UISplitViewController)
`-- rootNav (UINavigationController)
`-- hvc (HostManagerViewController, derived from UIViewController)
`-- detailViewController (DetailViewController, derived from UIViewController)
यह नीचे के रूप में अनुप्रयोग प्रतिनिधि में कार्यान्वित किया जाता
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
Console output:
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 3
Hostmanager: Viewdidload
Should rotate called to hostmanager with 1
Hostmanager: viewwillappear
लेकिन जब मैं '
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (UIInterfaceOrientationIsLandscape(interfaceOrientation));
}
फिर रों कोड' HostManagerViewController
बदलने HostManagerViewController की viewWillAppear` लागू नहीं है। कंसोल आउटपुट
Should rotate called to hostmanager with 1 (1 is the numeric value of interfaceOrientation)
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 3
Should rotate called to hostmanager with 3
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 3
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 3
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 3
Hostmanager: Viewdidload
Should rotate called to hostmanager with 1
केवल लैंडस्केप मोड Info.plist
संपादित में समर्थित हैं: सम्मिलित NSLog संदेशों shouldAutorotateToInterfaceOrientation
, viewWillAppear
और ViewDidLoad
क्या आपके लिए इस परियोजना का नमूना अपलोड करना संभव है? – ACBurk
आप इसे किस आईओएस संस्करण पर चल रहे हैं? – ACBurk
मैं 4.3 का उपयोग कर रहा हूँ। इसे एक छोटे टेस्टकेस को कम करना किया जा सकता है। मैं इसे कहां अपलोड करूं? –