Tag: appdelegate

简单的Webview:navigationDelegate开始崩溃

我的WebView有一个小问题。 这是我在我的应用程序中所做的: import UIKit import WebKit class ViewController: UIViewController, WKNavigationDelegate { @IBOutlet var webView: WKWebView! // draged from storyboard override func viewDidLoad() { super.viewDidLoad() var urlToLoad : (String) urlToLoad = "http://wwww.myapp.com" webView.sizeToFit() webView.isUserInteractionEnabled = true let url = URL(string: urlToLoad) let request = URLRequest(url:url!) //webView.navigationDelegate = self webView.load(request) } 正如你看到的行“webView.navigationDelegate = self”被评论。 如果我取消注释,我的应用程序将在开始时崩溃并告诉我: debugging器 :libc […]

iOS:如何在X小时内每隔一小时在睡眠模式下自动发送电子邮件与iPad?

我有办法发送完美的电子邮件,但是我想自动发送,即使iPad处于睡眠模式。 发送电子邮件的方式如下: 如何以编程方式在iOS中使用API​​ MailJet发送带附件的电子邮件? 提前致谢。

触摸appDelegate中的事件

这是我的问题。 我已经在我的应用程序中实现推送通知,它工作得很好。 该应用程序收到一条消息 在appDelegates中捕获:didReceiveRemoteNotification 创build一个新的UIView来显示接收到新消息 唯一的问题是,我希望用户能够点击消息,以便应用程序将打开消息viewcontroller。 但我似乎无法弄清楚如何捕捉这个触摸,然后在appDelegate中做些什么。 我有一个NSLog的方法,应该打开新的viewcontroller,但似乎从来没有被调用。 任何帮助,将不胜感激! 这是代码,它在didReceiveRemoteNotification方法中: UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoMessages)]; UIView *messageView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 45)]; messageView.userInteractionEnabled = YES; messageView.backgroundColor = [UIColor darkGrayColor]; [messageView addGestureRecognizer:recognizer]; [self.window addSubview:messageView]; 谢谢!

应用程序崩溃与exc_bad_access代码exception

让我介绍一下我的App的function,我使用推送通知和地址簿和CoreTelephony框架。 我在我的应用程序中做的是,当我得到推送通知,我保存在一个Appdelegatevariables(Incoming_NO)有效载荷的数字,如果没有这样的联系与这个数字,我会创build新的联系人并保存它。 当我收到呼叫时,同样的联系人名称会出现在我之前添加的,后来我允许用户编辑联系人,如果他想保存联系人或删除,当他编辑联系人,稍后当我收到推通知相同的号码我得到exc_bad_access (Incoming_NO)我已经启用僵尸,我得到了断点错误在同一地点.. 任何人都可以帮助我什么是问题。 Received notification: { aps = { alert = "Please help me-+918884718240"; sound = "beep.caf"; }; } 代码: NSString* alertValue = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"]; NSRange range=[alertValue rangeOfString:@":"]; NSString *param,*msg; NSRange range1=[alertValue rangeOfString:@":"]; if (range1.location != NSNotFound) { param = [alertValue substringFromIndex:range1.location + range1.length]; msg=[alertValue substringToIndex:range.location + range.length-1]; } else { range1=[alertValue […]

第一次启动应用后更改初始视图控制器

我有一个双视图login到我的应用程序,用户input两个值得信息的视图。 在用户input信息之后,我想要更改哪个视图是初始视图控制器,并使login视图成为类似设置的页面。 如何在用户通过应用程序中的某个点后更改初始视图控制器?

想从appdelegate调用ViewController的方法

我想在AppDelegate.m中调用ViewController的方法。 我在我的Viewcontroller有方法method()。我希望在appdelegate.m调用didSelectMethod()时调用它。 我已经打电话给这样的方法了。 ViewController *vc=[[ViewController alloc]init]; [vc method]; 方法被调用,但是与实际的方法具有相同的实例。 它具有所有的价值。 任何人都可以给我正确的代码,这是我想要的。 谢谢Jagveer Rana

访问XCTestCase类中的应用程序委托对象导致misaligned_stack_error_ swift

我正在尝试在swift中进行unit testing。 我定义了我的testing用例类,如下所示: import XCTest import CoreData import UIKit class LazyLoadingCheckTests: XCTestCase { var appDelegate : AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate override func setUp() { super.setUp() // Put setup code here. This method is called before the invocation of each test method in the class. } override func tearDown() { // Put teardown code here. […]

从AppDelegate显示两个ViewController

当APP启动时 – 启动SigninView – 它是Okey。 接下来,如果成功 – 我需要showTripController()。 function工作,但没有显示? 什么问题? func showSigninView() { let controller = self.window?.rootViewController!.storyboard?.instantiateViewControllerWithIdentifier("DRVAuthorizationViewController") self.window?.rootViewController!.presentViewController(controller!, animated: true, completion: nil) } func showTripController() { let cv = self.window?.rootViewController!.storyboard?.instantiateViewControllerWithIdentifier("DRVTripTableViewController") let nc = UINavigationController() self.window?.rootViewController!.presentViewController(nc, animated:true, completion: nil) nc.pushViewController(cv!, animated: true); }

从AppDelegate调用GameScene方法(Swift 3,SpriteKit,Xcode 8)

我使用Spritekit和SWIFT 3来创build游戏,我的问题是当我尝试从applicationWillResignActive(_ application: UIApplication)方法的AppDelegate文件中调用我的GameScene类(SKScene的子类)中的pauseGame applicationWillResignActive(_ application: UIApplication)方法。 我已经尝试实例化GameScene类,然后以这种方式调用我的AppDelegate文件中的方法,虽然没有编译器错误它不起作用: func applicationWillResignActive(_ application: UIApplication) { if let gameScene = GameScene(fileNamed: "GameScene") { gameScene.pauseGame() } } 我该如何解决这个问题? 提前致谢。

applicationWillEnterForeground提供一个视图控制器

每当- (void)applicationWillEnterForeground:(UIApplication *)application触发时,我都需要显示一个PIN视图控制器。 我有多个视图控制器,当应用程序进入后台,用户可以在任何一个。 问题是我不知道如何在目前处于活动状态的视图控制器上显示PIN视图控制器。 以下是我的实现看起来如何: – (void)applicationWillEnterForeground:(UIApplication *)application { ResourceSingleton *resource = [ResourceSingleton sharedSingleton]; if ([resource checkIfPINIsEnabled]) { PinViewController *pinView = [[PinViewController alloc] initWithMode:kPINViewControllerModeEnter]; pinView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; [self.window.rootViewController presentViewController:pinView animated:YES completion:NULL]; } } 但是,只有当我在第一个视图控制器(根目录)时,PIN视图才会出现。 如何在任何视图控制器上popup它? 我已经看到使用applicationwillenterforeground作为密码屏幕,但必须有更好的方法,或者我错了吗? 这将是对于iOS 7,所以如果只有7有这样的function它确定,但我很确定它也可以在6上完成。