UIWebView键盘的accessoryBar隐藏Word格式文档下载.docx

上传人:b****6 文档编号:20096471 上传时间:2023-01-16 格式:DOCX 页数:6 大小:16.63KB
下载 相关 举报
UIWebView键盘的accessoryBar隐藏Word格式文档下载.docx_第1页
第1页 / 共6页
UIWebView键盘的accessoryBar隐藏Word格式文档下载.docx_第2页
第2页 / 共6页
UIWebView键盘的accessoryBar隐藏Word格式文档下载.docx_第3页
第3页 / 共6页
UIWebView键盘的accessoryBar隐藏Word格式文档下载.docx_第4页
第4页 / 共6页
UIWebView键盘的accessoryBar隐藏Word格式文档下载.docx_第5页
第5页 / 共6页
点击查看更多>>
下载资源
资源描述

UIWebView键盘的accessoryBar隐藏Word格式文档下载.docx

《UIWebView键盘的accessoryBar隐藏Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《UIWebView键盘的accessoryBar隐藏Word格式文档下载.docx(6页珍藏版)》请在冰豆网上搜索。

UIWebView键盘的accessoryBar隐藏Word格式文档下载.docx

self.removeAccessoryBarForiOS8(keyboardWindowasUIView)

}else{

self.removeAccessoryBarForiOS7(keyboardWindowasUIView)

}

self.removeAccessoryBarForiOS9(UIApplication.sharedApplication().windows.last!

asUIView)

funcremoveAccessoryBarForiOS9(keyboardWindow:

UIView)->

forpossibleFormView:

UIViewinkeyboardWindow.subviews{

ifpossibleFormView.isMemberOfClass(NSClassFromString("

UIInputSetContainerView"

)!

){

forsubviewOfInputSetContainerViewinpossibleFormView.subviews{

ifsubviewOfInputSetContainerView.isMemberOfClass(NSClassFromString("

UIInputSetHostView"

forsubviewOfInputSetHostViewinsubviewOfInputSetContainerView.subviews{

//隐藏工具条NSClassFromString

ifsubviewOfInputSetHostView.isMemberOfClass(NSClassFromString("

UIWebFormAccessory"

subviewOfInputSetHostView.layer.opacity=0

subviewOfInputSetHostView.frame=CGRectZero

}elseif(subviewOfInputSetHostView.isMemberOfClass(NSClassFromString("

_UIRemoteKeyboardPlaceholderView"

)){

//这里使用了私有方法获取对应的accessorBar,然后进行隐藏

varaccessory=subviewOfInputSetHostView.performSelector(Selector("

placeheldView"

)).takeRetainedValue()

ifaccessory.isMemberOfClass(NSClassFromString("

letaccessory=accessoryas!

UIView

accessory.layer.opacity=0

accessory.frame=CGRectZero

//键盘背景,UIKBInputBackdropView有两个只隐藏上面的

elseifsubviewOfInputSetHostView.isMemberOfClass(NSClassFromString("

UIKBInputBackdropView"

)&

&

subviewOfInputSetHostView.frame.size.height<

100{

subviewOfInputSetHostView.userInteractionEnabled=false

funcremoveAccessoryBarForiOS8(keyboardWindow:

//隐藏工具条

funcremoveAccessoryBarForiOS7(keyboardWindow:

UIPeripheralHostView"

forsubviewOfPeripheralHostViewinpossibleFormView.subviews{

ifsubviewOfPeripheralHostView.isMemberOfClass(NSClassFromString("

subviewOfPeripheralHostView.layer.opacity=0

subviewOfPeripheralHostView.frame=CGRectZero

elseifsubviewOfPeripheralHostView.isMemberOfClass(NSClassFromString("

subviewOfPeripheralHostView.frame.size.height<

subviewOfPeripheralHostView.userInteractionEnabled=false

实际中,隐藏键盘accessory后的样子如下图:

webview_keyboard_hideaccessory.png

需要注意的是,在示例代码使用设置layer透明,frame为空来进行隐藏,而不使用removeFromSuperView,是因为使用了removeFromSuperView,在键盘重新布局时会导致crash。

当然如果有朋友解决了crash,使用removeFromSuperView会更好。

附:

上面示例代码Github地址

使用removeFromSuperView产生crash的崩溃栈:

2016-07-0614:

10:

32.018WebViewKeyBoard[10846:

930540]Theviewhierarchyisnotpreparedfortheconstraint:

Whenaddedtoaview,theconstraint'

sitemsmustbedescendantsofthatview(ortheviewitself).Thiswillcrashiftheconstraintneedstoberesolvedbeforetheviewhierarchyisassembled.Breakon-[UIView(UIConstraintBasedLayout)_viewHierarchyUnpreparedForConstraint:

]todebug.

930540]***Assertionfailurein-[UIInputSetHostView_layoutEngine_didAddLayoutConstraint:

roundingAdjustment:

mutuallyExclusiveConstraints:

],/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.60.7/NSLayoutConstraint_UIKitAdditions.m:

590

32.025WebViewKeyBoard[10846:

930540]***Terminatingappduetouncaughtexception'

NSInternalInconsistencyException'

reason:

'

Impossibletosetuplayoutwithviewhierarchyunpreparedforconstraint.'

***Firstthrowcallstack:

0CoreFoundation0x0000000105517d85__exceptionPreprocess+165

1libobjc.A.dylib0x00000001072bbdebobjc_exception_throw+48

2CoreFoundation0x0000000105517bea+[NSExceptionraise:

format:

arguments:

]+106

3Foundation0x0000000105968d5a-[NSAssertionHandlerhandleFailureInMethod:

object:

file:

lineNumber:

description:

]+198

4UIKit0x0000000106626b99__120-[UIView(UIConstraintBasedLayout)_layoutEngine_didAddLayoutConstraint:

]_block_invoke_2+254

5UIKit0x000000010662698b-[UIView(UIConstraintBasedLayout)_layoutEngine_didAddLayoutConstraint:

]+385

6UIKit0x0000000106626e04-[UIView(UIConstraintBasedLayout)_tryToAddConstraintWithoutUpdatingConstraintsArray:

]+65

7UIKit0x0000000106626f7d-[UIView(UIConstraintBasedLayout)_tryToAddConstraint:

]+288

8UIKit0x000000010662719f-[UIView(UIConstraintBasedLayout)_addConstraint:

]+274

9UIKit0x0000000106627438__50-[UIView(UIConstraintBasedLayout)addConstraints:

]_block_invoke+197

10Foundation0x00000001058f23d3-[NSISEnginewithBehaviors:

performModifications:

]+155

11UIKit0x0000000106626577-[UIView(UIConstraintBasedLayout)_withAutomaticEngineOptimizationDisabled:

]+58

12UIKit0x0000000106627348-[UIView(UIConstraintBasedLayout)addConstraints:

]+379

13UIKit0x00000001066b5531-[UIInputWindowControllerupdateViewConstraints]+3558

14UIKit0x00000001066b1fde-[UIInputSetHostView_didChangeKeyplaneWithContext:

]+224

15UIKit0x000000010650f1cc-[_UIKBCompatInputView_didChangeKeyplaneWithContext:

]+87

16UIKit0x0000000106004397-[UIKeyboard_didChangeKeyplaneWithContext:

]+324

17UIKit0x0000000105fe7b04-[UIKeyboardImpl_didChangeKeyplaneWithContext:

]+1100

18UIKit0x000000010620d5a3-[UIKeyboardLayoutStar(UIKeyboardLayoutJapanese50OnFlick)_didChangeKeyplaneWithContext:

]+183

19UIKit0x00000001061f121e-[UIKeyboardLayoutStarsetKeyplaneName:

]+4512

20UIKit0x0000000106209c37-[UIKeyboardLayoutStarsetShift:

]+158

21UIKit0x0000000105fec46a-[UIKeyboardImplnotifyShiftState]+73

22CoreFoundation0x000000010543cc37__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__+23

23CoreFoundation0x000000010543cba7__CFRunLoopDoObservers+391

24CoreFoundation0x00000001054326c4__CFRunLoopRun+836

25CoreFoundation0x00000001054320f8CFRunLoopRunSpecific+488

26GraphicsServices0x0000000109badad2GSEventRunModal+161

27UIKit0x0000000105d3ff09UIApplicationMain+171

28WebViewKeyBoard0x000000010532a242main+114

29libdyld.dylib0x0000000107d7f92dstart+1

30?

?

0x00000000000000010x0+1

libc++abi.dylib:

terminatingwithuncaughtexceptionoftypeNSException

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 幼儿教育 > 幼儿读物

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1