iOS:MFSideMenu在模拟器上显示黑屏

时间:2016-07-13 05:32:03

标签: ios iphone menu mfslidemenu

我将MFSideMenu导入我的虚拟项目。我使用以下代码

.h file

#import <UIKit/UIKit.h>
#import "MFSideMenu.h"
#import "RightSideViewController.h"
#import "MFSideMenuContainerViewController.h"

@interface xyzAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property(strong,nonatomic)UINavigationController * navigationController;
@property(strong, nonatomic) RightSideViewController * rightViewController;
@property(strong, nonatomic) MFSideMenuContainerViewController * container;

和.m文件是

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.


self.window= [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];

UIStoryboard * mainstoryboard = [UIStoryboard storyboardWithName:@"main" bundle:nil];
xyzViewController * vc = [mainstoryboard instantiateViewControllerWithIdentifier:@"xyzViewController"];
[self.navigationController pushViewController:vc animated:YES];

self.navigationController = [[UINavigationController alloc]initWithRootViewController:vc];



    self.rightViewController = [[RightSideViewController alloc]init];

    self.container = [MFSideMenuContainerViewController containerWithCenterViewController:self.navigationController leftMenuViewController:nil rightMenuViewController:_rightViewController];
    self.window.rootViewController = _container;
    [self.window makeKeyAndVisible];

    return YES;
}

当我运行项目时出现问题,它在模拟器上只显示黑屏。

请帮我解决这个问题

1 个答案:

答案 0 :(得分:0)

我自己解决了谢谢@ pkc456

我将以下代码添加到我的.m文件中,现在它可以正常工作

self.window= [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
UIStoryboard * mainstoryboard = [UIStoryboard storyboardWithName:@"main" bundle:nil];
xyzViewController * vc = [mainstoryboard instantiateViewControllerWithIdentifier:@"xyzViewController"];
[self.navigationController pushViewController:vc animated:YES];

self.navigationController = [[UINavigationController alloc]initWithRootViewController:vc];