用户拒绝定位,我将用户发送到设置应用程序上的位置设置:
UIApplication.sharedApplication().openURL(NSURL(string:"prefs:root=LOCATION_SERVICES")!)用户从设置应用程序授权定位,返回我的应用程序并在左上角显示Back to App
我怎么知道他回到应用程序了?viewDidAppear不起作用
发布于 2016-02-22 13:42:00
你可以通过检查AppDelegate's 来轻松地检测:-
func applicationWillEnterForeground(application: UIApplication!) {或者通过NSNotificationCenter在视图控制器的viewDidLoad()中注册通知:-
NSNotificationCenter.defaultCenter().addObserver(self, selector: "applicationWillEnterForeground", name: UIApplicationWillEnterForegroundNotification, object: nil)
//calling selector method
func applicationWillEnterForeground() {
println("did enter foreground")
}发布于 2016-02-22 13:41:36
发布于 2016-02-22 13:41:46
在viewController中使用NSNotificationCenter
在viewDidLoad上调用它
- (void)registerAppEnterForeground
{
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(applicationWillEnterForeground)
name:UIApplicationWillEnterForegroundNotification
object:nil];
}
-(void)applicationWillEnterForeground
{
/*HANDLE YOUR CODE HERE*/
}https://stackoverflow.com/questions/35546442
复制相似问题