Tag: appdelegate

用接口控制器重复架构x86_64的符号

我开始用WatchKit开发我的新应用程序。 在WatchKit扩展中,我有2个接口控制器。 当我在这两个接口控制器的两个.h文件中导入我的AppDelegate ,我收到以下错误: 'Id: 30 duplicate symbols for architecture x86_64' 这30个符号来自我的appDelegate.h 当我从两个界面控制器的任何一个.h文件中删除“ #Import "AppDelegate.h" ,问题就消失了。 但是,我使用在AppDelegate.h中定义的值出现新问题 最后,我不能在这两个文件中导入AppDelegate.h ,但是如果我没有(这certificate我不导入两次AppDelegate.h )会出现新的问题。 注意:我做了与我的应用程序的iPhone版ViewController一样,一切工作正常。 从问题可能来自哪里的任何暗示? 谢谢 编辑为bgilham : – 看不到“ .m ”文件 – 我不使用-Obj链接器标志 在iOS和WatchKit目标中有不同的名称 我使用相同的常量(在appdelegate.h定义) 我认为这是关系到AppDelegate.h因为它只发生在这个文件,而不是另一个。

我们如何检测iOS 7上的控制中心?

当控制中心出现在iOS 7上时,我遇到了问题。基本上,控制中心出现时会激发applicationDidEnterBackground。 但是在我的方法中,我想检测是否只是控制中心打开或通知中心,因为我会在该状态下对待applicationDidEnterBackground不同。 任何帮助,将不胜感激。

UIApplicationLaunchOptionsLocalNotificationKey始终为空 – iOS

我有一个使用本地通知的iOS应用程序。 当应用程序在后台运行或处于活动状态时,我使用application didReceiveLocalNotification方法,这很好。 但是,当应用程序closures(不在后台运行)时,我使用application didFinishLaunchingWithOptions方法来控制通知处理时发生的情况。 但是,我didFinishLaunchingWithOptions的问题是didFinishLaunchingWithOptions方法中的通知总是(null) 。 这是我的代码: -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. // Register the app for local notifcations. if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) { [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil]]; } // Setup the local notification check. UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; //UIAlertView *alertView = […]

在AppDelegate中使用Swift UINavigationBar setBackgroundImage

我试图设置一个背景图像全球导航栏中的应用程序委托在Swift中。 我可以让它在单独的View Controller上工作,像这样: var topBar: UINavigationBar! topBar.setBackgroundImage(UIImage(named: "navbar"), forBarMetrics: .Default) 但是,当我尝试将以下内容添加到应用程序委托,它崩溃与未捕获的exception: UINavigationBar.appearance().setBackgroundImage(UIImage(named: "navbar"), forBarMetrics: .Default)

iOS self.window – 它是什么时候创build的?

当你启动你的应用程序使用单个视图模板,并添加NSLog(@"self.window = %@", self.window); 在AppDelegate.m的application: didFinishLaunchingWithOptions:第一行application: didFinishLaunchingWithOptions:方法中,您可以看到self.window存在于您的应用程序中。 但是,当您使用空模板启动应用程序并尝试将self.windowlogging到控制台时,结果将返回null 。 即使添加了Storyboard和一个视图控制器,并将其视图控制器设置为初始视图控制器,并尝试loggingself.window ,结果也是一样的 – 它的值设置为null 。 并注意,无论你采取什么方式,你可以find你声明@property (strong, nonatomic) UIWindow *window; 在AppDelegate.h默认情况下。 所以我想知道为什么在第一种情况下,你可以看到self.window被初始化并设置了这个值,但是在后一种情况下没有。 另外,如果self.window已经在第一种情况下被声明和初始化,而在第二种情况下则不是,我怎样才能find初始化代码呢? 看起来在这两种情况下, @property声明是相同的 – 在这两种情况下,正如我所提到的,我尝试在AppDelegate.m的application: didFinishLaunchingWithOptions:的第一行loggingself.window的值application: didFinishLaunchingWithOptions:方法。 那么我错过了什么? 我不知道为什么这两个案件的行为不同,尽pipe我没有发现任何代码和故事板的差异。 我使用iOS 7和Xcode 5.谢谢。

如何阻止iOS 7控制中心控制音乐应用程序?

我们的应用程序通过成为远程控制事件的第一响应者,使用远程控制(例如iOS7以前的旧式跳板,耳塞式)明确阻止用户表单。 但是,在iOS7上,相同的代码无法绕过控制中心的音乐控制。 从testing中,控制中心似乎已经绕过了所有的音乐控制事件,包括UIEventSubtypeRemoteControlPause和UIEventSubtypeRemoteControlPlay,以及UIEventSubtypeRemoteControlTogglePlayPause。 控制中心是否有其自己的远程控制协议,或者在iOS7中截取远程控制事件的方式已经改变了? 相同的阻止代码仍然适用于iOS6设备。 以下是我们的工作: 在我们的appDelegate中添加了一个方法: (BOOL)canBecomeFirstResponder {return YES; } 在applicationDidBecomeActive中调用这个: [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; //将自己设置为第一响应者[self becomeFirstResponder]; 在applicationWillResignActive中调用这个 //closures远程控制事件传递[[UIApplication sharedApplication] endReceivingRemoteControlEvents]; //作为第一响应者[resignFirstResponder]; 最后补充说 (void)remoteControlReceivedWithEvent:(UIEvent *)receivedEvent { if (receivedEvent.type == UIEventTypeRemoteControl) { switch (receivedEvent.subtype) { case UIEventSubtypeRemoteControlTogglePlayPause: NSLog(@"Received: UIEventSubtypeRemoteControlTogglePlayPause\n"); break; case UIEventSubtypeRemoteControlPreviousTrack: NSLog(@"Received: UIEventSubtypeRemoteControlPreviousTrack\n"); break; case UIEventSubtypeRemoteControlNextTrack: NSLog(@"Received: UIEventSubtypeRemoteControlNextTrack\n"); break; case UIEventSubtypeRemoteControlPlay: NSLog(@"Received: UIEventSubtypeRemoteControlPlay\n"); break; case […]

其视图不在窗口层次结构中 – 电子邮件表单

我在appdelegate中从viewcontroller调用一个方法。 当我testingfunction时,我只是使用NSLog消息,它工作正常(所以viewcontroller和appdelegate之间的连接是好的)。 一旦我将电子邮件表单添加到此方法中,问题就出现了。 我收到的消息是: Warning: Attempt to present <MFMailComposeViewController: 0x1fdc3990> on <ViewController: 0x1fd9e3b0> whose view is not in the window hierarchy! 任何人知道该怎么办? 我知道有很多话题是“谁的观点不在窗口层级”的问题,但他们都没有帮助我。 ViewController.m … -(void)mail{ NSLog(@"blablabla"); if ([MFMailComposeViewController canSendMail]) { MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init]; mail.mailComposeDelegate = self; [mail setSubject:@"Hello and welcome!"]; NSArray *toRecipients = [NSArray arrayWithObject:@"tomas.javnicky@gmail.com"]; [mail setToRecipients:toRecipients]; [mail setCcRecipients:toRecipients]; NSString *emailBody […]

核心数据NSManagedObject没有有效的NSEntityDescription

我试图用我的Xcode项目设置核心数据,并运行一个我似乎无法摆脱的错误。 在StudyHub.xcdatamodeld有一个名为UserDetails的实体。 我在AppDelegate中的代码: // MARK: – Core Data stack lazy var persistentContainer: NSPersistentContainer = { /* The persistent container for the application. This implementation creates and returns a container, having loaded the store for the application to it. This property is optional since there are legitimate error conditions that could cause the creation of the […]

iOS背景获取和完成块

我正在试图定义这个方法 – (void)backgroundFetchWithCompletion:(void(^)(UIBackgroundFetchResult))completionHandler; 不过,我得到一个错误UIBackgroundFetchResult说没有types的参数列表只是允许的,我按照本教程和本教程 ,这是他们如何定义他们的方法。

从AppDelegate.swift为一个视图控制器分配一个值

我尝试从AppDelegate.swift分配一个值到一个视图控制器没有成功。 我的控制器名为DestinationsViewController ,它在Main.storyboard中的id是destinationsID 。 DestinationsControllerembedded在导航控制器中。 我想改变的对象被命名为“标签”。 这是代码: if let destinationsViewController = storyBoard.instantiateViewControllerWithIdentifier("destinationsID") as? DestinationsViewController { if let label = destinationsViewController.label{ label.text = "Super!" } else{ println("Not good 2") } } else { println("Not good 1") } 不幸的是,我收到这样的消息:“不好2”。 不是很好 :-( 谢谢。 import UIKit class DestinationsViewController: UIViewController { @IBOutlet weak var label: UILabel! override func viewDidLoad() { […]