禁用您如何檢測是否Safari瀏覽器已經在iPhone上的家長控制禁用如何檢測?我知道這是可能的,因爲App X3Watch拒絕工作,直到Safari被禁用。據我所見,家長控制沒有api,那麼可以使用哪種技術呢?如果是Safari瀏覽器在iPhone上
5
A
回答
4
我沒有測試過這一點,但OS3.0或更高版本,可以檢測一個URL可以用[[UIApplication sharedApplication] canOpenURL:myURL]
系統上的任何應用程序中打開。我敢打賭,如果Safari被禁用,它將返回NO
。
0
這裏是我的嘗試包括在一個視圖控制器解決這個。這兩個布爾需要使用,因爲用戶可以在加載視圖時獨立於Safari瀏覽器打開外部程序,但需要Safari瀏覽器的按鈕尚未打開。
@implementation ViewController {
@private BOOL externalProgramOpened;
@private BOOL buttonPressed;
}
-(void) setExternalProgramOpened {
// Only set to yes if we're trying to open safari
if(buttonPressed) {
externalProgramOpened = YES;
}
}
-(void) notifyUserOfRestrictedAccess {
if(externalProgramOpened == NO) {
[[[UIAlertView alloc] initWithTitle:@"Safari Needs to be enabled!"
message:@"It looks like the Safari browser is
disabled. Please enable it
(Settings>General>Restrictions) in order to
continue."
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles: nil] show];
} else {
externalProgramOpened = NO;
}
buttonPressed = NO;
}
-(void) viewWillAppear:(BOOL)animated {
externalProgramOpened = NO;
buttonPressed = NO;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(setExternalProgramOpened)
name:UIApplicationWillResignActiveNotification
object:nil];
}
-(void) viewWillDisappear:(BOOL)animated {
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIApplicationWillResignActiveNotification
object:nil];
[super viewWillDisappear:animated];
}
- (IBAction)buttonPressed:(id)sender {
buttonPressed = YES;
NSString * URL = *someURL*;
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:URL]];
[self performSelector:@selector(notifyUserOfRestrictedAccess) withObject:self
afterDelay:.75];
}
相關問題
- 1. iPhone safari瀏覽器API?
- 2. 確定iPhone用戶是否在Safari瀏覽器屏幕上
- 3. 如何在iPhone上獲得Safari瀏覽器書籤?
- 4. 如果從Chrome或Safari瀏覽器
- 5. 顯示Safari瀏覽器瀏覽網頁在iPhone
- 6. 瀏覽或選擇文件按鈕,在iPhone Safari瀏覽器
- 7. Safari瀏覽器
- 8. iPhone,移動Safari瀏覽器,YouTube的...留
- 9. iphone safari瀏覽器html對齊問題
- 10. 打開鏈接到Safari瀏覽器(iPhone)
- 11. UITextField調整寬度,如iPhone上的Safari瀏覽器
- 12. Android Web瀏覽器在iPhone上縮小Safari等內容嗎?
- 13. 按鈕不工作在iPhone上的Safari瀏覽器
- 14. HTML,CSS-Animation:漂浮在iPhone Safari上不像其他瀏覽器
- 15. 是否有可能在Safari瀏覽器在iPhone上,一邊聽到iPod
- 16. 在仿真器和Safari瀏覽器上工作,但不在真正的iPhone上
- 17. 浮動在Safari瀏覽器
- 18. 如何在Safari瀏覽器(Web瀏覽器)運行小程序
- 19. 動畫無法在iphone上使用jQuery移動容器上的Safari瀏覽器
- 20. 如何讓mp3文件在iPhone Safari瀏覽器中播放?
- 21. Angularjs計算不適用於iPad/iPhone上的Safari瀏覽器
- 22. iPhone/iPod上的移動Safari瀏覽器CSS破解
- 23. iphone上的自動縮放Safari瀏覽器
- 24. iPhone上的Safari瀏覽器:CSS定位1px
- 25. 如何確定iOS6 safari瀏覽器是全屏還是瀏覽器模式?
- 26. 是否可以從iPhone safari瀏覽器獲取UDID?
- 27. IPhone 5S移動Safari瀏覽器的超鏈接不是「點擊」
- 28. 訪問HTTP:iPad上的Safari瀏覽器// myWindowsMachine
- 29. Javascript/Rails Cookie不保存在Safari瀏覽器,但在Chrome瀏覽器上工作
- 30. 位置粘貼在Mozilla瀏覽器無法在Safari瀏覽器上工作
是的,我試過了,你說得對。謝謝! – zorro2b 2010-06-19 12:33:16
這是否仍然有效?我在iOS 6(iPad 3)上嘗試了這一點,但即使在限制中禁用了Safari,它也會返回YES。但是,如果我實際調用openURL :, Safari在禁用時不會打開,如預期的那樣。 – Michael 2012-11-01 17:19:32
回答我自己的問題:[鏈接](http://stackoverflow.com/questions/12771177/uiapplications-canopenurl-openurl-return-misleading-result) – Michael 2012-11-01 17:51:38