Objective c 使用revealToggle:method(SWRevealViewController类)时滑出导航不起作用
我已经在我的项目中成功地实现了SWRevealViewController类 但当我使用revealtogle:method作为我的左栏按钮项操作时,它会显示一个完整的黑屏。景色完全是黑色的。 但是当我使用RightRevealtogle:方法时,视图会正常加载 我包括AppDelegate.h、AppDelegate.m和主视图的代码 滑出视图现在是空视图。只是背景颜色改变了 检查一下,告诉我出了什么问题 这是模拟器中项目的屏幕截图 AppDelegate.hObjective c 使用revealToggle:method(SWRevealViewController类)时滑出导航不起作用,objective-c,ios7,swrevealviewcontroller,Objective C,Ios7,Swrevealviewcontroller,我已经在我的项目中成功地实现了SWRevealViewController类 但当我使用revealtogle:method作为我的左栏按钮项操作时,它会显示一个完整的黑屏。景色完全是黑色的。 但是当我使用RightRevealtogle:方法时,视图会正常加载 我包括AppDelegate.h、AppDelegate.m和主视图的代码 滑出视图现在是空视图。只是背景颜色改变了 检查一下,告诉我出了什么问题 这是模拟器中项目的屏幕截图 AppDelegate.h 我已经找到了解决我问题的办法
我已经找到了解决我问题的办法 我的教练帮我解决了这个问题 这是经过编辑的代码 谢谢你的帮助 AppDelegate.h
如果你从不接受答案。没有人愿意帮助你。什么。。??!!!我什么时候说过,我不会接受帮助。…???我完全陷入困境,我请求你的帮助…我不知道出了什么问题,我正在等待一些有经验的人来帮助我。。。我不明白,你为什么说我不接受答案。。!!!???对不起,我的第一个问题。我忘了用initwithnibname。我过了一会儿才发现。我想,我接受了一个答案。。。对于第二个问题,我根本没有得到任何答案。。那家伙让我重新措辞我的问题。。。但是,到那时,我已经解决了这个错误。。我回答这个问题是因为没有人回答。。。至于这篇文章,这是我的第三个问题这是我的错误,我不知道,我没有接受第一个问题的答案。我刚刚发现我必须点击绿色的勾号图标来接受答案。。。不会再发生这种事了,我没有开枪和逃跑。我真诚地向你们道歉。。。我应该做得更好。。。
// AppDelegate.h
// IndianBloodBank
//
// Created by Roshith Balendran on 8/5/14.
// Copyright (c) 2014 Olympus. All rights reserved.
//
#import <UIKit/UIKit.h>
@class SWRevealViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) SWRevealViewController *splitMenu;
@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
- (void)saveContext;
- (NSURL *)applicationDocumentsDirectory;
@end
// AppDelegate.m
// IndianBloodBank
//
// Created by Roshith Balendran on 8/5/14.
// Copyright (c) 2014 Olympus. All rights reserved.
//
#import "AppDelegate.h"
#import "SWRevealViewController.h"
#import "HomePageViewController.h"
#import "SlideOutMenuViewController.h"
#import "SearchViewController.h"
#import "SearchViewController.h"
#import "AboutUsViewController.h"
#import "SponsorsViewController.h"
#import "HowToDonateViewController.h"
#import "EmergencyViewController.h"
@interface AppDelegate()<SWRevealViewControllerDelegate>
@end
@implementation AppDelegate
@synthesize splitMenu,window;
@synthesize managedObjectContext = _managedObjectContext;
@synthesize managedObjectModel = _managedObjectModel;
@synthesize persistentStoreCoordinator = _persistentStoreCoordinator;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window = window;
HomePageViewController *HPVC = [[HomePageViewController alloc]init];
SlideOutMenuViewController *SOMVC = SOMVC = [[SlideOutMenuViewController alloc]init];
UINavigationController *frontNavigationController = [[UINavigationController alloc]initWithRootViewController:HPVC];
UINavigationController *rearNavigationController = [[UINavigationController alloc]initWithRootViewController:SOMVC];
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.125 green:0.122 blue:0.133 alpha:1]];
SWRevealViewController *revealController= [[SWRevealViewController alloc]initWithRearViewController:rearNavigationController frontViewController:frontNavigationController];
revealController.rearViewRevealWidth = 120;
revealController.rearViewRevealOverdraw = 120;
revealController.bounceBackOnOverdraw = NO;
revealController.stableDragOnOverdraw = YES;
[revealController setFrontViewPosition:FrontViewPositionLeft];
revealController.delegate=self;
revealController.rightViewController = SOMVC;
self.splitMenu = revealController;
self.window.rootViewController = self.splitMenu;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
// HomePageViewController.m
// IndianBloodBank
//
// Created by Roshith Balendran on 8/5/14.
// Copyright (c) 2014 Olympus. All rights reserved.
//
#import "HomePageViewController.h"
#import "SWRevealViewController.h"
#import "AboutUsViewController.h"
#import "SponsorsViewController.h"
#import "HowToDonateViewController.h"
#import "SearchViewController.h"
@interface HomePageViewController ()
@end
@implementation HomePageViewController
@synthesize btn1SearchBlood,btn2DonateNow;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.navigationController.navigationBar.translucent=NO;
SWRevealViewController *revealViewController = [self revealViewController];
[revealViewController panGestureRecognizer];
[revealViewController tapGestureRecognizer];
UIView* MenuButtonView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 25, 20)];
UIButton* MenuButton=[UIButton buttonWithType:UIButtonTypeSystem];
MenuButton.frame=MenuButtonView.frame;
[MenuButton setImage:[UIImage imageNamed:@"v1_menu-icon"] forState:UIControlStateNormal];
MenuButton.tintColor=[UIColor grayColor];
MenuButton.autoresizesSubviews=YES;
MenuButton.autoresizingMask=UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin;
[MenuButton addTarget:revealViewController action:@selector(revealToggle:) forControlEvents:UIControlEventTouchUpInside];
[MenuButtonView addSubview:MenuButton];
UIBarButtonItem *Menu=[[UIBarButtonItem alloc]initWithCustomView:MenuButtonView];
self.navigationItem.leftBarButtonItem=Menu;
}
// AppDelegate.h
// IndianBloodBank
//
// Created by Roshith Balendran on 8/5/14.
// Copyright (c) 2014 Olympus. All rights reserved.
//
#import <UIKit/UIKit.h>
@class SWRevealViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) SWRevealViewController *splitMenu;
@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
- (void)saveContext;
- (NSURL *)applicationDocumentsDirectory;
@end
// AppDelegate.m
// IndianBloodBank
//
// Created by Roshith Balendran on 8/5/14.
// Copyright (c) 2014 Olympus. All rights reserved.
//
#import "AppDelegate.h"
#import "SWRevealViewController.h"
#import "HomePageViewController.h"
#import "SlideOutMenuViewController.h"
#import "SearchViewController.h"
#import "SearchViewController.h"
#import "AboutUsViewController.h"
#import "SponsorsViewController.h"
#import "HowToDonateViewController.h"
#import "EmergencyViewController.h"
@interface AppDelegate()<SWRevealViewControllerDelegate>
@end
@implementation AppDelegate
@synthesize splitMenu,window;
@synthesize managedObjectContext = _managedObjectContext;
@synthesize managedObjectModel = _managedObjectModel;
@synthesize persistentStoreCoordinator = _persistentStoreCoordinator;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
// self.window = window;
HomePageViewController *HPVC = [[HomePageViewController alloc]initWithNibName:@"HomePageViewController" bundle:nil];
SlideOutMenuViewController *SOMVC ;
SOMVC = [[SlideOutMenuViewController alloc]init];
UINavigationController *frontNavigationController = [[UINavigationController alloc]initWithRootViewController:HPVC];
// UINavigationController *rearNavigationController = [[UINavigationController alloc]initWithRootViewController:SOMVC];
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.078 green:0.09 blue:0.078 alpha:1]];
splitMenu= [[SWRevealViewController alloc]initWithRearViewController:SOMVC frontViewController:frontNavigationController];
splitMenu.rearViewRevealWidth = 120;
splitMenu.rearViewRevealOverdraw = 120;
splitMenu.bounceBackOnOverdraw = NO;
splitMenu.stableDragOnOverdraw = YES;
[splitMenu setFrontViewPosition:FrontViewPositionLeft];
splitMenu.delegate=self;
splitMenu.rightViewController = SOMVC;
self.window.rootViewController = splitMenu;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
// HomePageViewController.m
// IndianBloodBank
//
// Created by Roshith Balendran on 8/5/14.
// Copyright (c) 2014 Olympus. All rights reserved.
//
#import "HomePageViewController.h"
#import "SWRevealViewController.h"
#import "AboutUsViewController.h"
#import "SponsorsViewController.h"
#import "HowToDonateViewController.h"
#import "SearchViewController.h"
@interface HomePageViewController ()
@end
@implementation HomePageViewController
{
SWRevealViewController *slideController;
}
@synthesize btn1SearchBlood,btn2DonateNow;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.navigationController.navigationBar.translucent=NO;
slideController = [self revealViewController];
//[revealViewController panGestureRecognizer];
// [revealViewController tapGestureRecognizer];
UIView* MenuButtonView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 25, 20)];
UIButton* MenuButton=[UIButton buttonWithType:UIButtonTypeSystem];
MenuButton.frame=MenuButtonView.frame;
[MenuButton setImage:[UIImage imageNamed:@"v1_menu-icon"] forState:UIControlStateNormal];
MenuButton.tintColor=[UIColor grayColor];
MenuButton.autoresizesSubviews=YES;
MenuButton.autoresizingMask=UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin;
[MenuButton addTarget:slideController action:@selector(revealToggle:) forControlEvents:UIControlEventTouchUpInside];
[MenuButtonView addSubview:MenuButton];
UIBarButtonItem *Menu=[[UIBarButtonItem alloc]initWithCustomView:MenuButtonView];
self.navigationItem.leftBarButtonItem=Menu;
}