sirven que por para los inicio gestos flotante control boton assistive objective-c ios7 tabs slidingmenu

objective c - que - Cómo hacer un menú deslizante con pestañas en ios



ios 12 (1)

Estoy usando ZUUIRevealController Library.

Archivo Appdelegate.h

(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window = window; UITabBarController *tabBarController=[[UITabBarController alloc]init]; FrontViewController *frontViewController = [[FrontViewController alloc] init]; RearViewController *rearViewController = [[RearViewController alloc] init]; MapViewController *frontViewController2 = [[MapViewController alloc] init]; UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:frontViewController]; UINavigationController *navigationController2 = [[UINavigationController alloc] initWithRootViewController:frontViewController2]; RevealController *revealController = [[RevealController alloc] initWithFrontViewController:navigationController rearViewController:rearViewController]; RevealController *revealController2 = [[RevealController alloc] initWithFrontViewController:navigationController2 rearViewController:rearViewController]; [revealController.tabBarItem setTitle:@"Home"]; [revealController2.tabBarItem setTitle:@"Absent note"]; revealController.tabBarItem.image=[[UIImage imageNamed:@"home_icon.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; revealController2.tabBarItem.image=[[UIImage imageNamed:@"absent_note_icon.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; [tabBarController setViewControllers:[NSArray arrayWithObjects:revealController,revealController2,nil]]; [self.window setRootViewController:tabBarController]; [self.window makeKeyAndVisible]; return YES; }

FrontViewController.m

- (void)viewDidLoad { [super viewDidLoad]; self.title = NSLocalizedString(@"Front View", @"FrontView"); if ([self.navigationController.parentViewController respondsToSelector:@selector(revealGesture:)] && [self.navigationController.parentViewController respondsToSelector:@selector(revealToggle:)]) { UIPanGestureRecognizer *navigationBarPanGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self.navigationController.parentViewController action:@selector(revealGesture:)]; [self.navigationController.navigationBar addGestureRecognizer:navigationBarPanGestureRecognizer]; [self.view addGestureRecognizer:navigationBarPanGestureRecognizer]; self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Slide", @"Slide") style:UIBarButtonItemStylePlain target:self.navigationController.parentViewController action:@selector(revealToggle:)]; } }

RearViewController es un Table ViewController

MapViewController.m

- (void)viewDidLoad { [super viewDidLoad]; self.title = NSLocalizedString(@"Map View", @"MapView"); if ([self.navigationController.parentViewController respondsToSelector:@selector(revealGesture:)] && [self.navigationController.parentViewController respondsToSelector:@selector(revealToggle:)]) { UIPanGestureRecognizer *navigationBarPanGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self.navigationController.parentViewController action:@selector(revealGesture:)]; [self.navigationController.navigationBar addGestureRecognizer:navigationBarPanGestureRecognizer]; [self.view addGestureRecognizer:navigationBarPanGestureRecognizer]; self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Slide", @"Slide") style:UIBarButtonItemStylePlain target:self.navigationController.parentViewController action:@selector(revealToggle:)]; } }

Las pestañas funcionan correctamente, pero el menú deslizante no funciona correctamente.

Primero hago clic en la pestaña Inicio y en el menú Diapositiva para ver la diapositiva Controlador de vista. Luego hice clic en la segunda pestaña y en el menú deslizante para ver la diapositiva Controlador de vista. Nuevamente he hecho clic en la pestaña Inicio y en el menú deslizante para ver el Controlador de vista de diapositivas. No se puede mostrar solo muestra una pantalla negra.


Encontré la solución para ese problema. en el archivo de Appdelegate escribí la llamada a swreavealtoggle para navegación.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window = window; HomeViewController *frontViewController = [[HomeViewController alloc] init]; SlideViewController *rearViewController = [[SlideViewController alloc] init]; UINavigationController *frontNavigationController = [[UINavigationController alloc] initWithRootViewController:frontViewController]; UINavigationController *rearNavigationController = [[UINavigationController alloc] initWithRootViewController:rearViewController]; SWRevealViewController *revealController = [[SWRevealViewController alloc] initWithRearViewController:rearNavigationController frontViewController:frontNavigationController]; revealController.delegate = self; self.viewController = revealController; [self.window setRootViewController:self.viewController]; [self customizeInterface]; [self.window makeKeyAndVisible]; return YES;}

A continuación, cree un viewController para agregar componentes de un elemento Tabbar. El nombre de Myviewcontroller es HomeViewController.h después de incluir el botón de elemento de pestaña, haga clic en acción.

#import <UIKit/UIKit.h> @interface HomeViewController : UIViewController<UITabBarDelegate>{ UITabBar *mainTabBar; UIViewController *tab1vc; // view controller of first tab UIViewController *tab2vc; // view controller of second tab UIViewController *tab3vc; // view controller of first tab UIViewController *tab4vc; // view controller of second tab } @property (nonatomic, retain) IBOutlet UITabBar *mainTabBar; @property (nonatomic, retain) UIViewController *tab1vc; @property (nonatomic, retain) UIViewController *tab2vc; @property (nonatomic, retain) UIViewController *tab3vc; @property (nonatomic, retain) UIViewController *tab4vc;

@fin

HomeViewController.m

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item { // item is the selected tab bar item switch (item.tag) { case 1: if (tab1vc == nil) { self.tab1vc =[[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil]; } [self.view insertSubview:tab1vc.view belowSubview:mainTabBar]; self.title = @"Home"; label.text = self.title; //[tab1vc release]; NSLog(@"1st"); break; case 2: if (tab2vc == nil) { self.tab2vc =[[Tab2 alloc] initWithNibName:@"Tab2" bundle:nil]; } [self.view insertSubview:tab2vc.view belowSubview:mainTabBar]; //[tab2vc release]; self.title = @"Tab2"; label.text = self.title; NSLog(@"2st"); break; case 3: if (tab3vc == nil) { self.tab3vc =[[Tab3 alloc] initWithNibName:@"Tab3" bundle:nil]; } [self.view insertSubview:tab3vc.view belowSubview:mainTabBar]; //[tab2vc release]; self.title = @"Tab3"; label.text = self.title; NSLog(@"3rd"); break; case 4: if (tab4vc == nil) { self.tab4vc =[[Tab4 alloc] initWithNibName:@"Tab4" bundle:nil]; } [self.view insertSubview:tab4vc.view belowSubview:mainTabBar]; //[tab2vc release]; self.title = @"Tab4"; label.text = self.title; NSLog(@"4th"); break; default: break; }

}

Ahora está funcionando bien