相关疑难解决方法(0)

从Swift中的AppDelegate获取ViewController的实例

我试图在用户单击UILocalNotification时从swift中的app delegate加载特定的ViewController.我已经发现在这个函数中调用了它:

func application(application: UIApplication!, didReceiveLocalNotification notification: UILocalNotification!)
Run Code Online (Sandbox Code Playgroud)

但是当我尝试访问其中一个打开的ViewControllers时,我认为它返回null,因为我的应用程序正在崩溃.这是我正在尝试的:

var rootViewController = self.window!.rootViewController
var storyBoard = rootViewController.storyboard
var setViewController = storyBoard.instantiateViewControllerWithIdentifier("CurrentShows") as ViewController_CurrentShows

rootViewController.navigationController.popToViewController(setViewController, animated: false)
setViewController.reloadData()
Run Code Online (Sandbox Code Playgroud)

它在popToViewController行崩溃了.

ios appdelegate swift

19
推荐指数
1
解决办法
3万
查看次数

pushViewController不起作用

我是新来的iOS 迅速swrevealviewcontroller。我面临一个问题!在我的幻灯片菜单中(场景TableViewController,有两个蓝线绘制),在选中时,每行然后应打开粒子scene(视图控制器),但是不幸的是它没有打开。didselectRowAt当我从表中选择行但pushViewController不起作用时,没有错误和火灾。

  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

        let dvcStoryBordId = menuViewIds[(indexPath.row - 1 )]

        let viewController = storyboard?.instantiateViewController(withIdentifier: dvcStoryBordId )

        self.navigationController?.pushViewController(viewController!, animated: true)
    }
Run Code Online (Sandbox Code Playgroud)

故事板

在此处输入图片说明

我想念什么吗?这是正确的方法吗?自。

更新:

self.navigationControllernil。还有其他选择吗?或没有导航

更新:

情节提要ID

menuViewIds = ["shareWithFriends","deliveryTracking", "controls", "support","myAccount"]
Run Code Online (Sandbox Code Playgroud)

运行时视图

在此处输入图片说明

ios swrevealviewcontroller swift

5
推荐指数
1
解决办法
8264
查看次数

标签 统计

ios ×2

swift ×2

appdelegate ×1

swrevealviewcontroller ×1