开发者

How do you disable the iPhone keyboard Go button when a textfield is focused inside a UIWebView?

One the screens within my app shows a UIWebView with a HTML web form. Currently开发者_如何学Go when a textfield is focused and the keyboard appears a Go button is shown. Currently I have no user for the Go button and clicking it does nothing.

How can this button be disabled or removed, or how can I change the keyboard that is showing in a UIWebView?


I think the only option you have is to register for a call back when keyboard will show and get a UIView reference to the keyboard and add a Disabled looking Go button over the Actual Go Button in the keyboard.

1) First register for keyboardWillshow notification..

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil];

2) IN your keyboardWillShow function traverse through all subViews of app window to get a reference to keyboard..

UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];

UIView* keyboard;

//Iterate though each view inside of the selected Window
for(int i = 0; i < [tempWindow.subviews count]; i++){
keyboard = [tempWindow.subviews objectAtIndex:i];
if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES){
//Keyboard is now a UIView reference to the UIKeyboard we want. From here we can add a subview
//to th keyboard like a new button
}
}

code shamelessly copied from this link..Look at it..a very informative thread..

I dont know if any other method out there..Hope it will be useful..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜