你們是否有任何想法如何調用一個方法每次某個uiwebview在頁面上完成時,即。所以它不能向上滾動?這個功能非常適合以智能方式刷新頁面。Xcode 4.5確定如果uiwebview可以向上滾動
/埃裏克
你們是否有任何想法如何調用一個方法每次某個uiwebview在頁面上完成時,即。所以它不能向上滾動?這個功能非常適合以智能方式刷新頁面。Xcode 4.5確定如果uiwebview可以向上滾動
/埃裏克
您可以使用這樣的事情:
在.H,你的代碼應該是這個樣子:
@interface iSafeViewController : UIViewController <UIWebViewDelegate, UIScrollViewDelegate>
然後在.M
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
//The webview is is scrolling
float scrollViewHeight = scrollView.frame.size.height;
float scrollContentSizeHeight = scrollView.contentSize.height;
float scrollOffset = scrollView.contentOffset.y;
if (scrollOffset <= 1)
{
// then we are at the top
}
else if (scrollOffset + scrollViewHeight >= scrollContentSizeHeight - 1)
{
// then we are at the end
}
else
{
//We are somewhere in the middle
}
}
您將需要設置您的webView的scrollView刪除博意門,雖然是這樣的:
[webView.scrollView setDelegate:self];
如果不工作讓我知道。
UIWebView
有一個scrollView
財產。這是UIScrollView
組要委託什麼都反對:
@property(nonatomic, assign) id<UIScrollViewDelegate> delegate
現在,您將得到所有的委託回調:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView
它的偉大工程,謝謝!有一件事,我得到這個問題:發送'FirstViewController * const __strong'到不兼容類型'id'的參數。你知道我如何擺脫它嗎?它在「[webView.scrollView setDelegate:self];」在.m文件中。 –
user1981282
2013-02-12 16:16:35
哦,是的,在你的頭文件中,添加UIScrollViewDelegate。爲了清晰起見,我會編輯我的asnwer。 – Josiah 2013-02-12 16:33:04
再次感謝您!這在iPad上非常好,但在iPhone上卻不行,你明白爲什麼?我有相同的標題和實施文件鏈接到iPhone和iPad,但有兩個不同的uiwebviews。 – user1981282 2013-02-12 20:37:56