gpt4 book ai didi

ios - 如何在 iPad 的 UISplitViewController 中隐藏 MasterViewController

转载 作者:行者123 更新时间:2023-12-01 18:57:59 24 4
gpt4 key购买 nike

I am working with UISplitViewController,where i need to hide MasterViewController for 1st DetailViewController. Means,when app launches,the MasterViewController must be hidden without clicking on any UIButton. I tried using UISplitViewController inside UIViewControllers.But nothing happened. After that I tried to develop overall app within UISplitViewController. Here is the code I tried to hide MasterViewController


masterViewController = [splitViewController.viewControllers objectAtIndex:0];
detailVC = [splitViewController.viewControllers objectAtIndex:1];
[master.view setFrame:CGRectMake(0, 0, 0, 0)];
detail.view.frame = splitViewController.view.bounds;

I have spent my 1 week doing this,but nothing worked.Please provide solution.It would be great pleasure.



更新 :

Ok done with hiding master view controller.But when i set delegate to detail view controller,it hides master view controller for all view controllers. Here is my appDelegate's code where I am adding UISplitViewController.


self.splitViewController =[[UISplitViewController alloc]init];

MasterTableViewController *masterViewController=[[MasterTableViewController alloc]initWithNibName:@"MasterTableViewController" bundle:nil];

UINavigationController *masterNavigate=[[UINavigationController alloc]initWithRootViewController:masterViewController];

DetailViewController *detailVC=[[DetailViewController alloc]initWithNibName:@"DetailViewController" bundle:nil];

UINavigationController *detailNavigate=[[UINavigationController alloc]initWithRootViewController:detailVC];

self.splitViewController.viewControllers=[NSArray arrayWithObjects:masterNavigate,detailNavigate, nil];

self.splitViewController.delegate=detailVC;

self.window.rootViewController=self.splitViewController;

Here,I set delegate of splitViewController to detailVC.In detailViewController with Nex Mishra's code I am hiding master view controller and when I navigate to other views from detailVC,it hides the master view controller. I know it would be irritating,But it would be helpful.

最佳答案

您可以使用此委托(delegate)方法来隐藏主 VC。

- (BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation
{
//Add your own logic to when you want the master VC hidden.
return YES;
}

关于ios - 如何在 iPad 的 UISplitViewController 中隐藏 MasterViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25358516/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com