In iOS7 Text Magnifier isn't working app wide

╄→尐↘猪︶ㄣ 提交于 2019-11-27 01:39:18

问题


I have a came across a rather annoying bug in one of my apps. In iOS7 when I hold down on a UITextView or UITextField to bring up the Magnifying Glass, nothing shows up in the magnified area. This problem is app wide and the only element that ever shows up in the circle area is the keyboard itself (when I drag my finger down to the top of it).

I have tried everything from View Controllers with only a single UITextView to UIWebView and the problem is app wide.

The magnifying glass works as expected on iOS6 devices, and the iOS7 simulator. But not on any of the devices I have tested it with running iOS7.

Any help would be greatly appreciated.


回答1:


I fixed this by setting the windowLevel of my main window to a float value of 1.2 in appDelegate:

self.window.windowLevel = 1.2;

This is a sort of hack for iOS7 to raise the default level of your main window which is UIWindowLevelNormal (1.0) to 1.2




回答2:


Had the same issue when using multiple windows at once. Setting correct .windowLevel value for each window for correct z-sorting solved the problem.




回答3:


We have a similar problem where we were presenting a UIWindow over the top of the existing window and if they have the same windowLevel then the loupe displays the first window added.

example:

[applicationWindow (windowLevel = 0] <------------- [customWindow (windowLevel = 0)]

customWindow renders on top of applicationWindow just fine...but a loupe displayed over a textfield in custom window renders the contents of applicationWindow.

[applicationWindow (windowLevel = 1] <------------- [customWindow (windowLevel = 1)]

Same result. customWindow renders on top of applicationWindow just fine...but a loupe displayed over a textfield in custom window renders the contents of applicationWindow.

[applicationWindow (windowLevel = 0] <------------- [customWindow (windowLevel = 1.01)]

customWindow renders correctly, contents of loupe render correctly.

The way we solved it is by initing customWindow.windowLevel to be UIApplication sharedApplication].keyWindow.windowLevel + .01 (but this could be anything) before making our customWindow the keyWindow. Thanks @user2940692, your answer should probably be the accepted one... if you want it, i'll post our case as a question, you can answer it and I'll give you credit.




回答4:


I had the same issue. I found that in Project -> Targets -> General that there was a nib listed in the "Main Interface". Once I removed that it works fine. I also tried setting the window level, and it worked, but it was just masking the true problem for me.




回答5:


If you did not get any help from the above solutions, I found another problem which can cause this to happen. I had a UIWindow object in nib which was initialized in AppDelegate. That view had background color as [UIColor whiteColor]. Setting it to [UIColor clearColor] will resolve this problem.



来源:https://stackoverflow.com/questions/19039581/in-ios7-text-magnifier-isnt-working-app-wide

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!