[英]iphone - PushViewController does not work With Reveal Controller
我正在創建一個iPhone應用程序,其中在主視圖控制器類中有許多網格視圖。 所以,我想當我從主視圖中選擇一個網格單元時,應該加載一個Reveal控制器。 布局看起來像
我的主視圖控制器中包含以下代碼。
-(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];
}
在主視圖控制器.h文件中,
@property (strong, nonatomic) SWRevealViewController *revealController;
我也聲明了SWRevealViewControllerDelegate。 問題是此self.revealController無法加載/顯示。 我也嘗試使用App Delegate,但沒有任何效果。 謝謝。
我解決了:使用以下代碼。
-(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];
}
}
並在Class.h文件中
@property(nonatomic, strong) UINavigationController *myNavigationController;
@property(nonatomic, strong) SWRevealViewController *viewController1;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.