ios - 滑出式菜单 VC 黑屏

标签 ios objective-c iphone swrevealviewcontroller

我正在使用 SWViewController Library .实现库时,我的 frontViewController 出现了,但我的 rearViewController 是黑色的。我不知道是什么导致了这个问题,需要一些帮助。该应用程序完全使用 Objective C 编程。此应用程序没有 swift 也没有 Storyboard。

这是我的 rearViewController.h 代码:

#import <UIKit/UIKit.h>

@interface RearViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, retain) IBOutlet UITableView *rearTableView;

@end

rearViewController.m:

#import "RearViewController.h"

#import "SWRevealViewController.h"




@interface RearViewController()

{
    NSInteger _presentedRow;
}

@end

@implementation RearViewController

@synthesize rearTableView = _rearTableView;


#pragma mark - View lifecycle


- (void)viewDidLoad
{
    [super viewDidLoad];

    self.title = NSLocalizedString(@"Rear View", nil);
}

我的 appDelegate.h 代码:

@class SWRevealViewController;

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) TARootViewController  *rootViewController;
@property (strong, nonatomic) SWRevealViewController *viewController;

@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 代码:​​

    #import "AppDelegate.h"

    #import "SWRevealViewController.h"
    #import "RearViewController.h"

    @interface AppDelegate()<SWRevealViewControllerDelegate>
    @end

    @implementation AppDelegate

    @synthesize window = _window;
    @synthesize viewController = _viewController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window = window;
    RearViewController *rearViewController = [[RearViewController alloc] init];
    TARootViewController *frontViewController = [[TARootViewController alloc] init];
    SWRevealViewController *revealController = [[SWRevealViewController alloc] initWithRearViewController:rearViewController frontViewController:frontViewController];
    revealController.delegate = self;

    self.window.rootViewController = revealController;
    [self.window makeKeyAndVisible];


    if (self.rootViewController.activeViewController == nil) {
        [[TAActiveUserManager sharedManager] startOrResumeAppSession];
    }


    // Register device for push notifications
    UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
                                                    UIUserNotificationTypeBadge |


    UIUserNotificationTypeSound);
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
                                                                             categories:nil];
    [application registerUserNotificationSettings:settings];
    [application registerForRemoteNotifications];

    return YES;
}

there is more here but it's not relevant to initializing the viewcontrollers

最佳答案

我也在 reddit 上问过这个问题,并且 here是回答我问题的线程。

事实证明,黑色是 SWRevealViewController 的默认 viewController 颜色 - 仅仅因为它是黑色并不意味着它没有正确加载。

关于ios - 滑出式菜单 VC 黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31844617/

相关文章:

objective-c - Shell 脚本调用错误 - 已删除的 Fabric 框架仍保留在项目中

ios - 选中时的 Tabman Image Tint 颜色

ios - 从 xib 文件中以模态方式呈现 View Controller

objective-c - KVO 产生错误/未收到通知

ios - 将数据从一个 UIViewController 委托(delegate)给另一个

iphone - 递增属性 int (self.int++)

iphone - 多行上的 UILabel 自动居中文本,但我希望它保持文本的位置

iphone - 是否有适用于 ‘With Friends’ 游戏的 iOS API?

ios - 如何在 iOS 11 中制作类似 Appstore 的页面

ios编程: Using threads to add multiple images to library