Tag: appdelegate

获取推送通知的设备令牌

我正在推送通知。 我写了下面的代码来获取设备令牌。 – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. // Add the view controller's view to the window and display. [self.window addSubview:viewController.view]; [self.window makeKeyAndVisible]; NSLog(@"Registering for push notifications…"); [[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)]; return YES; } – (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { NSString *str = [NSString stringWithFormat:@"Device […]

UIStatusBarStyle不能在Swift中工作

我试图改变我的Swift应用程序的状态栏颜色为白色,但我打砖墙。 我有3个ViewControllers每个embedded在一个NavigationController(可能是这个问题?我已经尝试将代码放在NavigationController类。)我已经在我的AppDelegate的didFinishLaunchingWithOptions中尝试了以下两段代码.swift文件,但都没有工作。 application.statusBarStyle = .LightContent 和 UIApplication.sharedApplication().statusBarStyle = .LightContent 所有的文档必须要说的是,UIBarButtonStyle是一个Int,并给了我这个枚举片段,这并没有帮助我在所有的implimentation。 enum UIStatusBarStyle : Int { case Default case LightContent case BlackOpaque } 我错过了什么?

从应用程序委托使用swift打开视图控制器

我正在尝试创build一个推送通知,根据从推送中获得的信息确定要打开哪个视图。 我已经设法从推动中获得信息,但我现在正在努力争取开放的观点 看看其他堆栈溢出问题我目前有以下几点: 应用程序委托完成加载: //Extract the notification data if let notificationPayload = launchOptions?[UIApplicationLaunchOptionsRemoteNotificationKey] as? NSDictionary { // Get which page to open let viewload = notificationPayload["view"] as? NSString let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) //Load correct view if viewload == "circles" { var viewController = self.window?.rootViewController?.storyboard?.instantiateViewControllerWithIdentifier("Circles") as! UIViewController self.window?.rootViewController = viewController } } […]

iOS – 从ViewController调用App Delegate方法

我想要做的是点击一个button(它是在代码中创build的),让它调用一个不同的视图控制器,然后让它在新的视图控制器中运行一个函数。 我知道在IB可以做得相对容易,但这不是一个select。 我想要做的一个例子是,如果你有两个视图控制器,一个房子的闪屏。 另一个视图控制器已经走过了房子,你可以按照设定的顺序通过所有的房间。 启animation面将有每个房间的button,让你跳到任何点的步行。

AppDelegate,rootViewController和presentViewController

我正在做的Facebook集成教程,我想显示我的MainViewViewController,如果用户有一个有效的标记为当前状态,否则我想显示LoginViewController。 MainViewAppDelegate.m – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) { // To-do, show logged in view } else { // No, display the login page. [self showLoginView]; } return YES; } – (void)showLoginView { UIStoryboard *mainstoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; LoginViewController* loginViewController = [mainstoryboard instantiateViewControllerWithIdentifier:@"LoginViewController"]; [self.window.rootViewController presentViewController:loginViewController animated:YES completion:NULL]; } 控制台错误: Warning: […]

NSInternalInconsistencyException',原因:'无法在捆绑中加载NIB:'NSBundle

在我的AppDelegate有一个我不明白的问题。 RootViewController最初叫ViewController,我改了它的名字。 应用程序是由许多ViewController组成,然后我引入了一个UINavigationController。 为什么这个错误来了? NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle /Users/XXXXXXXXXXXX/Library/Application Support/iPhone simulator/6.0/Applications/ B7A7D461-1CFE-4B05-AF32-00B65FCFFF49/XXXXXXXXXX.app> (loaded)'with name 'RootViewController'' *** First throw call stack: (0x1992012 0x1357e7e 0x1991deb 0x4bafac 0x37fe37 0x380418 0x380648 0x380882 0 x380b2a 0x397ef5 0x397fdb x398286 0x398381 0x398eab 0x398fc9 0x399055 0x49e3ab 0x2ef92d 0x136b6b0 0x1f12fc0 0x1f0733c 0x1f12eaf 0x38e8cd 0x2d71a6 0x2d5cbf 0x2d5bd9 0x2d4e34 0x2d4c6e 0x2d5a29 […]