2013-10-28 1 views
2

iPad 앱에 사용자 입력이 필요한 로그인 필드가있는 UIWebView이 있습니다. 보기는 모달로 표시되고 가로로 놓으면 UIWebView이 위로 스크롤되는 키보드가 표시됩니다.

여기 버그가 발생합니다. UIWebView에는 안정적인 해결책을 찾지 못한 탭 지연이 있습니다. (Javascript 주입이 안정적으로 작동하지 않으므로 OAuth을 사용하고 있습니다.) 키보드가 표시되므로 입력 필드를 탭하면보기가 자동으로 스크롤 된 후 올바른 위치에 있지 않아 탭이 등록됩니다.UIWebView 스크롤. 탭 오프셋 버그가 발생 했습니까?

본질적으로, 이것은 상단 입력 필드를 탭하므로, 뷰는 키보드로 이동하기 때문에 약 20px보다 낮게 등록됩니다.

UIWebView을 스크롤하지 못하도록 시도했지만 키보드가 무엇이든 상관없이 항상 이동합니다. 나는 탭 지연을 제거하기 위해 Javascript을 주입하려고했지만 거기에서도 성공하지 못했습니다.

도움을 주시면 감사하겠습니다.

답변

2

나는이 동일한 문제로 분투하고 있습니다. 나는 아직하지만 지금까지 사용을 할 수있는 탭 지연 해제로 탭 오프셋 문제가 해결되지 않은 : 당신이 아직이 페이지를 발견 한 경우

[[self.webView scrollView] setDelaysContentTouches:NO]; 

확실하지,하지만 당신은 키보드 알림 리스너를 추가 할 수 있으며 자신을 스크롤 조작. 여기 https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html

보기 조작에 관한 링크에서 코드입니다 :있는 UIWebView 항상 키보드와 함께 이동하지 않는 내

// Call this method somewhere in your view controller setup code. 
- (void)registerForKeyboardNotifications 
{ 
[[NSNotificationCenter defaultCenter] addObserver:self 
     selector:@selector(keyboardWasShown:) 
     name:UIKeyboardDidShowNotification object:nil]; 

[[NSNotificationCenter defaultCenter] addObserver:self 
     selector:@selector(keyboardWillBeHidden:) 
     name:UIKeyboardWillHideNotification object:nil]; 

} 


// Called when the UIKeyboardDidShowNotification is sent. 
- (void)keyboardWasShown:(NSNotification*)aNotification 
{ 
NSDictionary* info = [aNotification userInfo]; 
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size; 

UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, kbSize.height, 0.0); 
scrollView.contentInset = contentInsets; 
scrollView.scrollIndicatorInsets = contentInsets; 

// If active text field is hidden by keyboard, scroll it so it's visible 
// Your app might not need or want this behavior. 
CGRect aRect = self.view.frame; 
aRect.size.height -= kbSize.height; 
if (!CGRectContainsPoint(aRect, activeField.frame.origin)) { 
    [self.scrollView scrollRectToVisible:activeField.frame animated:YES]; 
} 
} 

// Called when the UIKeyboardWillHideNotification is sent 
- (void)keyboardWillBeHidden:(NSNotification*)aNotification 
{ 
UIEdgeInsets contentInsets = UIEdgeInsetsZero; 
scrollView.contentInset = contentInsets; 
scrollView.scrollIndicatorInsets = contentInsets; 
} 

그것은 일부 히트 영역처럼 보인다는 여기에 애플의 문서 링크입니다. 한 가지 더러운 해킹은 보이지 않는 텍스트 div를 버튼 위에 놓고/etc에 공백을 두어 터치 이벤트가 등록되지 않은 것을 성취하려고하는 자바 스크립트 함수를 호출하는 것입니다. 좋아요 :

<div id="someBtn" onclick="tryAction();">&nbsp;&nbsp;&nbsp;&nbsp;</div> 

이 정보가 도움이되었거나 유용한 방향으로 나올 수 있기를 바랍니다.

+0

어디에서 변수 activeField를 얻고 있습니까? – HaloZero

관련 문제