我在自己的app内通过[[UIApplication sharedApplication] openURL:[NSURL URLWithString:htmlStr ]];
调用safari,在浏览器里处理完之后,再回到自己的app,我希望能在这时执行一个方法。
这该怎么做?要怎么判断是从safari返回app的?
1.写一个判断在applicationDidBecomeActive 这里。设置一个标志BOOL isJump 默认为NO.
if(isJump){
function();//这里设置isJump 为NO
}
2.
在[[UIApplication sharedApplication] openURL:[NSURL URLWithString:htmlStr ]]; //这里设置isJump 为YES
应该能满足需求吧
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(becomeActive) name:UIApplicationDidBecomeActiveNotification object:nil];
监控唤醒的函数就行了 不过要做好判断