0

プロジェクトに SWRevealViewController クラスを正常に実装しました。

https://github.com/John-Lluch/SWRevealViewController

しかし、左バー ボタン アイテムのアクションとして RevealToggle: メソッドを使用すると、完全な黒い画面が表示されます。ビューは完全に黒です。しかし、rightRevealToggle: メソッドを使用すると、ビューは正常に読み込まれます。

AppDelegate.h、AppDelegate.m、およびメイン ビューのコードを含めています。

スライド アウト ビューは現在空のビューです。背景色だけ変えました。

それをチェックして、何が間違っているか教えてください。

これは、シミュレーターでのプロジェクトのスクリーンショットです

http://i57.tinypic.com/mljpe9.png

AppDelegate.h

//  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

//  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

//  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;


}
4

1 に答える 1

1

私は自分の問題の解決策を見つけました...

私のトレーナーは私がそれを解決するのを手伝ってくれました。

これが編集されたコードです。

助けてくれてありがとう。

AppDelegate.h

//  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

//  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

//  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;


}
于 2014-08-31T09:01:25.270 に答える