【问题标题】:Integrating PKRevealController with Storyboards将 PKRevealController 与 Storyboard 集成
【发布时间】:2014-06-15 19:55:45
【问题描述】:

我希望集成 PKRevealController 并为我的应用程序提供一个整体的滑动设置菜单。 我找不到任何有关使用情节提要的教程。我已经有一个故事板,它承载了一个导航控制器(默认情况下),带有一个指向 rootviewcontroller 的箭头(在我的例子中称为 LoginViewController)。

按照 PKRevealController 的任何文档,我添加了一个单独的 Viewcontroller 场景并将其类设为 PKRevealController,然后在应用程序委托中执行此操作

@interface AhmAppDelegate() <PKRevealing>
@property (nonatomic, strong, readwrite) PKRevealController *revealController;
@end 

@implementation AmAppDelegate

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

self.revealController = (PKRevealController *)self.window.rootViewController;
self.window.rootViewController = self.revealController;
LoginViewController *frontViewController = [[UIStoryboard storyboardWithName:@"Mainview_iPad" 
 bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
[self.revealController setFrontViewController:frontViewController];//This throws the error

return YES;

}

运行时出现以下错误

   Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 
    '-[UINavigationController setFrontViewController:]: unrecognized selector sent to instance 
   0xb17aec0'

我做错了什么?

【问题讨论】:

    标签: ios storyboard


    【解决方案1】:

    艾迪,

    我遇到了类似的问题,并认为这是因为我的故事板。然而,仔细观察,崩溃的线路试图访问UIViewController上的.revealController

    .revealController 已通过UIViewController 上的类别实现,我记得您无法在不添加链接器标志的情况下从静态库加载类别。

    在安装说明中,它说添加链接器标志-ObjC,为此请转到您的项目Build Settings 并搜索Other Linker Flags,然后添加-ObjC。

    由于我使用了另一个库,我没有使用此标志,这意味着它正在尝试加载我不希望包含的其他库。为了解决这个问题,我特别要求它只加载 PKReveal 库:

    -force_load $(BUILT_PRODUCTS_DIR)/libPKRevealController.a
    

    希望这会帮助其他人,因为我花了一段时间:/

    W

    【讨论】:

      猜你喜欢
      • 2013-01-30
      • 2012-01-21
      • 2017-04-04
      • 2020-10-08
      • 2013-07-19
      • 1970-01-01
      • 2019-05-30
      • 2016-04-10
      • 2016-10-26
      相关资源
      最近更新 更多