videos para ocultar fotos contraseña con como carpetas aplicacion iphone ipad ios5 customization uisplitviewcontroller

iphone - para - Cómo ocultar y mostrar el controlador Master View en el controlador SplitView



como ocultar fotos en un iphone 8 (11)

''setNeedsLayout'' hace que UISplitViewController solicite "shouldHideViewController"

- (IBAction)hideUnhide:(id)sender { UISplitViewController* spv = ...; self.hideMaster= !self.hideMaster; [ spv.view setNeedsLayout ] }

He creado un nuevo proyecto basado en vista dividida en mi XCode 4.2

Luego, en el archivo DetailViewController.m tengo que agregar este método

- (BOOL)splitViewController: (UISplitViewController*)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation { //This method is only available in iOS5 return NO; }

Ahora, al hacer esto, puedo mostrar las partes izquierda y derecha de mi controlador Splitview a la vez.

Ahora agregué un UIBarButtonItem en mi DetailViewController navegación DetailViewController y deseo usar lo que puedo ocultar y mostrar mi vista maestra tanto en modo Portrairt como en modo horizontal.

- (IBAction)hideUnhide:(id)sender { //How can hide & unhide }

¿Cómo puedo hacer esto?


Bueno, la parte fácil de su pregunta es usar un bool, decir una propiedad hideMaster, y luego

- (IBAction)hideUnhide:(id)sender { self.hideMaster= !self.hideMaster; }

y entonces...

- (BOOL)splitViewController: (UISplitViewController*)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation { //This method is only available in iOS5 return self.hideMaster; }

Eso funciona bien, pero solo se debe llamar a hidHideViewController durante un redibujado de splitVC, como durante una rotación, por lo que el maestro solo se esconde / no se oculta.


Combiné las respuestas anteriores y los siguientes trabajos bien en iOS 6:

// In split delegate -(void)hideMaster:(BOOL)hideState { _masterIsHidden = hideState; [self.splitViewController.view setNeedsLayout]; self.splitViewController.delegate = nil; self.splitViewController.delegate = self; [self.splitViewController willRotateToInterfaceOrientation:[UIApplication sharedApplication].statusBarOrientation duration:0]; } -(BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation { return self.masterIsHidden; }


En cuanto al comentario de wzbozon acerca de no tener que reasignar al delegado, encontré que las dos líneas

self.splitViewController.delegate = nil; self.splitViewController.delegate = self;

... no se necesitaron en el simulador, pero sí en mi iPad5 con iOS5. Sin ellos, no se produjo el comportamiento de ocultar / mostrar (al hacer clic en el botón no se contrajo la vista maestra).


En iOS 5.1 tienes que hacerlo de esta manera:

Dentro de DetailViewController.m

- (IBAction)hideUnhide:(id)sender { UISplitViewController* spv = ...; self.hideMaster= !self.hideMaster; [spv.view setNeedsLayout]; spv.delegate = nil; spv.delegate = self; } - (BOOL)splitViewController:(UISplitViewController*)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation { return self.hideMaster; }


En iOS8 esto es fácil.

Para esconderlo

[UIView animateWithDuration:0.2 animations:^{ splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModePrimaryHidden; } completion:nil];

Para mostrarlo

[UIView animateWithDuration:0.2 animations:^{ self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModePrimaryOverlay; } completion:nil];


Puede mostrar / ocultar el ViewController maestro activando la acción de la propiedad UISplitViewController de UISplitViewController :

Rápido

if let displayModeButtonItem = splitViewController?.displayModeButtonItem() { displayModeButtonItem.target?.performSelector(displayModeButtonItem.action) }

C objetivo

UIBarButtonItem *displayModeButtonItem = [self.splitViewController displayModeButtonItem]; [displayModeButtonItem.target performSelector: displayModeButtonItem.action];

Me parece más apropiado que entrometerme con el delegado, la orientación y el diseño al mismo tiempo.


SWIFT 3.0

he usado

override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if segue.identifier == "showDetail" { if let indexPath = self.tableView.indexPathForSelectedRow { let object = self.exercises[indexPath.row] let controller = (segue.destination as! UINavigationController).topViewController as! DetailViewController controller.detailItem = object controller.navigationItem.leftBarButtonItem = self.splitViewController?.displayModeButtonItem controller.navigationItem.leftItemsSupplementBackButton = true UIView.animate(withDuration: 0.2, delay: 0.0, options: [.curveEaseOut], animations: { self.splitViewController?.preferredDisplayMode = .primaryHidden }, completion: nil) } } }


instead spv.delegate=nil; spv.delegate=self;

tienes que hacer lo siguiente:

[spv willRotateToInterfaceOrientation:self.interfaceOrientation duration:0];


-(IBAction)clickToShowMaster:(id)sender { UIBarButtonItem *systemItem1 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"prev.png"] style:UIBarButtonItemStylePlain target:self action:@selector(clickToHidemaster:)]; self.navigationItem.leftBarButtonItem = systemItem1; [self.tabBarController.tabBar setHidden:NO]; [self hideMaster:NO]; } -(void)hideMaster:(BOOL)hideState { ishideMaster=hideState; [self.splitViewController.view setNeedsLayout]; self.splitViewController.delegate = nil; self.splitViewController.delegate = self; [self.splitViewController willRotateToInterfaceOrientation:[UIApplication sharedApplication].statusBarOrientation duration:0]; } -(void)hideMaster:(BOOL)hideState { ishideMaster=hideState; [self.splitViewController.view setNeedsLayout]; self.splitViewController.delegate = nil; self.splitViewController.delegate = self; [self.splitViewController willRotateToInterfaceOrientation:[UIApplication sharedApplication].statusBarOrientation duration:0]; } #pragma mark - Split view -(BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation { if(UIInterfaceOrientationIsPortrait(orientation)) { UIBarButtonItem *systemItem1 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"down.png"] style:UIBarButtonItemStylePlain target:self action:@selector(showPopup)]; self.navigationItem.leftBarButtonItem = systemItem1; [self setUIforPortrait]; return YES; } if (UIInterfaceOrientationIsLandscape(orientation)) { if(ishideMaster==TRUE) { UIBarButtonItem *systemItem1 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"next.png"] style:UIBarButtonItemStylePlain target:self action:@selector(clickToShowMaster:)]; self.navigationItem.leftBarButtonItem = systemItem1; [self setUIForFullLandscape]; } else { UIBarButtonItem *systemItem1 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"prev.png"] style:UIBarButtonItemStylePlain target:self action:@selector(clickToHidemaster:)]; self.navigationItem.leftBarButtonItem = systemItem1; [self setUIForHalfLandscape]; } return ishideMaster; } } //add the navigation button on left top, to pop-up master view. - (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController { [barButtonItem setImage:[UIImage imageNamed:@"down.png"]]; UIBarButtonItem *systemItem1 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"down.png"] style:UIBarButtonItemStylePlain target:self action:@selector(showPopup)]; self.navigationItem.leftBarButtonItem = systemItem1; self.masterPopoverController = popoverController; self.masterPopoverController.delegate=self; } - (void)splitViewController:(UISplitViewController *)splitController willShowViewController:(UIViewController *)viewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem { // Called when the view is shown again in the split view, invalidating the button and popover controller. //; if(UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) { if(ishideMaster==FALSE) { UIBarButtonItem *systemItem1 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"prev.png"] style:UIBarButtonItemStylePlain target:self action:@selector(clickToHidemaster:)]; self.navigationItem.leftBarButtonItem = systemItem1; } else { UIBarButtonItem *systemItem1 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"next.png"] style:UIBarButtonItemStylePlain target:self action:@selector(clickToShowMaster:)]; self.navigationItem.leftBarButtonItem = systemItem1; } } else if(UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) { [self.navigationItem setLeftBarButtonItem:nil animated:YES]; } //self.masterPopoverController = nil; }


- (BOOL)splitViewController:(UISplitViewController*)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation { [spv.view setNeedsLayout]; //add the line return self.hideMaster; }