let UIWebView pop up the button on the keyboard to display the Chinese http://www.cr173.com/html/19440_1.html
If you have the following questions, this article may help you.
- The keyboard covers the UIWebView.
- How to remove the keyboard by dragging UIWebView.
- When the keyboard appears, the content contents of the UIWebView move up, and the focused text box is outside the viewable area of the UIWebView.
- How to prevent the content of UIWebView from moving up when the keyboard pops up.
- Coordinates cannot be obtained in UIWebView to calculate contentoffset to get the results you want to show.
+-------------------------+
Step by step instructions: 1. Call out Remove keyboard
Just click the HTML TextBox control inside the UIWebView and the keyboard will pop up automatically. Of course you need to get the information of the keyboard (height, etc.), method or use Uiviewcontroller+notification way, the code is as follows:
//Uikeyboardwillshownotification and uikeyboardwillhidenotification the name of the iOS system post notification when the keyboard is ejected or removed. You only need to define self as the recipient of this notification. //viewwillappear: And viewwilldisappear: It should be clear to everyone that the two methods are executed after self loadview and Removefromsuperview respectively. //Special Note: Here the object parameter needs to be nil, otherwise cannot take the keyboard the UserInfo- (void) Viewwillappear: (BOOL) animated {[Super viewwillappear:animated]; [[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (keyboardwillshow:) Name: UikeyboardwillshownotificationObject: nil]; [[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (keyboardwillhide:) Name: UikeyboardwillhidenotificationObject: nil]; } - (void) Viewwilldisappear: (BOOL) animated {[Super viewwilldisappear:animated]; [[Nsnotificationcenter Defaultcenter] removeobserver:self name:uikeyboardwillshownotificationObject: nil]; [[Nsnotificationcenter Defaultcenter] removeobserver:self name:uikeyboardwillhidenotificationObject: nil]; } - (void) Keyboardwillshow: (Nsnotification *) Notification {nsdictionary*userinfo =[Notification UserInfo]; Nsvalue* Value =[UserInfo Objectforkey:uikeyboardframeenduserinfokey]; CGRect Keyboardrect= [value cgrectvalue];//this gets the keyboard frame .//your actions, such as keyboard appearance, control view Move up, etc.} - (void) Keyboardwillhide: (Nsnotification *) Notification {//Get info with the above method//your actions, such as keyboard removal, control view restore, etc.}2. Remove the keyboard by dragging UIWebView
Seeing a lot of people on the internet has done a lot to implement this feature, but in iOS7 Apple has provided these to us, the code is as follows:
// Remove keyboard when dragging
If it is iOS7 below, please refer to 6来 settings, approximate idea, first add a private flag to indicate whether the keyboard exists now, when present, through the 6来 get the event off the keyboard.
3. The keyboard covers the UIWebView
This solution can be done in 1 keyboardwillshow: Inside, by changing the origin of WebView.
4. When the keyboard appears, the content contents of the UIWebView move up, and the focused text box is beyond the viewable area of the UIWebView.
In the UIWebView, as long as the keyboard appears, UIWebView will definitely move upward, as for the fit is not good to say, if not appropriate, only with disable automatic movement.
5. How to prevent the content of UIWebView from moving up when the keyboard pops up
This method, I also looked for a long time, but still found, thanks to powerful netizens, the code is as follows:
@interface // add uiscrollviewdelegate, step 1 Self.webView.scrollView. Delegate // Registered agent, Step 2 // implementing the Proxy method, step 3 return nil; }
6. How to get the click coordinates in UIWebView
As we all know, UIWebView will eat all the touch events, or there will not be so many people to make JavaScript, but can not be set does not mean that can not be replaced by another way, the idea: to WebView superview add gestures, Then by implementing multi-gesture filtering settings, why do you want to set up multi-gesture filtering? I would like to explain here, because UIWebView default has its own gesture, it will intercept your gestures, so that superview can not receive gestures, the code is as follows:
@interfaceXxx:uiviewcontroller<uigesturerecognizerdelegate>//add uigesturerecognizerdelegate, step 1//add gestures, step 2UITapGestureRecognizer *webtap =[[UITapGestureRecognizer alloc] initwithtarget:self action: @selector (Webtap:)]; Webtap.numberoftouchesrequired=1; Webtap.numberoftapsrequired=1; Webtap.Delegate=Self ; Webtap.cancelstouchesinview=NO; [Self.view Addgesturerecognizer:webtap]; //set filter, Ruturn Yes to receive at the same time, this gesture can be through webview, so that your superview can also receive, Step 3-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldrecognizesimultaneouslywithgesturerecognizer: (Uigesturerecognizer *) othergesturerecognizer{returnYES; } - (void) Webtap: (UITapGestureRecognizer *) sender{Cgpoint tappoint= [Sender LocationInView:self.webView.scrollView];//gets the coordinates relative to the webview and, if changed to Self.view, gets the coordinates relative to the Superview, step 4NSLog (@"tappoint x:%f y:%f", TAPPOINT.X,TAPPOINT.Y); }
UIWebView keyboard processing can think of only these, welcome to add.
Transferred from: http://www.open-open.com/lib/view/open1408609311366.html
IOS UIWebView Keyboard Handling