[英]iphone - PushViewController does not work With Reveal Controller
I am creating an iphone application, where i have number of grid views in a main view controller class. 我正在创建一个iPhone应用程序,其中在主视图控制器类中有许多网格视图。 So, i want when i select a grid cell from main view, should load a Reveal controller. 所以,我想当我从主视图中选择一个网格单元时,应该加载一个Reveal控制器。 The layout looks like 布局看起来像
I have the following code in my Main View Controller. 我的主视图控制器中包含以下代码。
-(void) gridView:(UzysGridView *)gridView didSelectCell:(UzysGridViewCell *)cell
atIndex:(NSUInteger)index
{
if (index == 0){
FrontViewController *frontViewController = [[FrontViewController alloc]
init];
RightViewController *rightViewController = [[RightViewController alloc] init];
UINavigationController *frontNavigationController = [[UINavigationController alloc]
initWithRootViewController:frontViewController];
SWRevealViewController *mainRevealController = [[SWRevealViewController alloc]
initWithRearViewController:nil
frontViewController:frontNavigationController];
mainRevealController.delegate = self;
self.revealController.rightViewController = rightViewController;
self.revealController = mainRevealController;
[self.navigationController pushViewController:self.revealController animated:YES];
}
here in main view controller .h file, 在主视图控制器.h文件中,
@property (strong, nonatomic) SWRevealViewController *revealController;
Also i have declare SWRevealViewControllerDelegate. 我也声明了SWRevealViewControllerDelegate。 Problem is that this self.revealController doesn't load/show. 问题是此self.revealController无法加载/显示。 I have tried with App Delegate also, but nothing works. 我也尝试使用App Delegate,但没有任何效果。 thanks. 谢谢。
I solved it: Use the below code.. 我解决了:使用以下代码。
-(void) gridView:(UzysGridView *)gridView didSelectCell:(UzysGridViewCell *)cell
atIndex:(NSUInteger)index {
if (index == 0){
FrontViewController *frontViewController = [[FrontViewController alloc]
init];
myNavigationController = [[UINavigationController alloc]
initWithRootViewController:frontViewController];
SWRevealViewController *revealController = [[SWRevealViewController alloc]
initWithRearViewController:nil frontViewController:myNavigationController];
revealController.delegate = self;
RightViewController *rightViewController =
[[RightViewController alloc] init];
rightViewController.view.backgroundColor = [UIColor greenColor];
revealController.rightViewController = rightViewController;
self.viewController1=revealController;
[self presentViewController:self.viewController1 animated:YES completion:nil];
}
}
And in Class.h file 并在Class.h文件中
@property(nonatomic, strong) UINavigationController *myNavigationController;
@property(nonatomic, strong) SWRevealViewController *viewController1;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.