问题描述
我想摆脱当您在 web 视图中聚焦文本字段时出现的键盘顶部的栏.我们有一些其他的方法来处理这个,这是多余的和不必要的.
i want to get rid of the bar on top of the keyboard that appears when you focus a text field in a webview. we have some other ways of handling this and it's redundant and unnecessary.
webview 键盘栏 http://beautifulpixel.com/assets/iphone_simulator-20100120-152330.png
如果您遇到此问题,请务必前往 http://www.51sjk.com/upload/articles/1/0/342/342963_20230209092032268.com 并复制 rdar://9844216
if you hit this problem, make sure to head over to http://www.51sjk.com/upload/articles/1/0/342/342963_20230209092032268.com and duplicate rdar://9844216
推荐答案
- (void)viewdidload { [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(keyboardwillshow:) name:uikeyboardwillshownotification object:nil]; } - (void)viewwillappear:(bool)animated { [super viewwillappear:animated]; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(keyboardwillshow:) name:uikeyboardwillshownotification object:nil]; } - (void)keyboardwillshow:(nsnotification *)notification { [self performselector:@selector(removebar) withobject:nil afterdelay:0]; } - (void)removebar { uiwindow *keyboardwindow = nil; for (uiwindow *testwindow in [[uiapplication sharedapplication] windows]) { if (![[testwindow class] isequal:[uiwindow class]]) { keyboardwindow = testwindow; break; } } for (uiview *possibleformview in [keyboardwindow subviews]) { // ios 5 sticks the uiwebformview inside a uiperipheralhostview. if ([[possibleformview description] rangeofstring:@"uiperipheralhostview"].location != nsnotfound) { for (uiview *subviewwhichispossibleformview in [possibleformview subviews]) { if ([[subviewwhichispossibleformview description] rangeofstring:@"uiwebformaccessory"].location != nsnotfound) { [subviewwhichispossibleformview removefromsuperview]; } } } } }
这很好用.
网址:http://ios-blog.co.uk/iphone-development-tutorials/rich-text-editor-inserting-images-part-6/