因此,我構建了一個自定義Web瀏覽器,其中包含許多自定義功能,但是我遇到了一些非常簡單的問題。我有一個的NSTimer:在我的自定義網頁瀏覽器中加載/刷新按鈕
[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(checkLoad) userInfo:nil repeats:YES];
,這裏是它調用方法:
-(void)checkLoad{
if (webView.loading) {
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
//add button to address bar
UIButton *stopButton = [UIButton buttonWithType:UIButtonTypeContactAdd];
stopButton.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
[stopButton addTarget:self action:@selector(stop) forControlEvents:UIControlEventTouchUpInside];
addressBar.rightView = stopButton;
addressBar.rightViewMode = UITextFieldViewModeUnlessEditing;
}
else if (!(webView.loading)) {
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
//add button to address bar
UIButton *refreshButton = [UIButton buttonWithType:UIButtonTypeInfoDark];
refreshButton.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
[refreshButton addTarget:self action:@selector(refresh) forControlEvents:UIControlEventTouchUpInside];
addressBar.rightView = refreshButton;
addressBar.rightViewMode = UITextFieldViewModeUnlessEditing;
}
}
的按鈕顯示出來就好了,頁面正在加載或沒有加載時,他們改變。但與他們的互動非常痙攣。刷新按鈕大部分時間都在工作,但停止按鈕幾乎不會起作用。我玩過NSTimer的時機,使它更長,更短,但無濟於事。
另外,我知道按鈕圖像是錯誤的,但這些只是佔位符,直到我可以刷新並停止加載Safari瀏覽器中的圖像。
有什麼想法?我完全願意做一些完全不同的事情來檢測頁面何時加載(這實際上是首選,因爲我不希望每隔0.2秒循環一次NSTimer,如果我可以避開它,但這是我能找到的唯一方法。
痙攣?在哪裏肌肉張力或大腦麻痹進入這個嗎?http://en.wikipedia.org/wiki/Spastic – occulus 2011-03-15 17:44:23