日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ios 不被遮挡 阴影_IOS开发之Bug--iOS7View被导航栏遮挡问题的解决

發(fā)布時間:2025/3/8 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ios 不被遮挡 阴影_IOS开发之Bug--iOS7View被导航栏遮挡问题的解决 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

在實際開發(fā)中,遇到在UITextView的frame等于當(dāng)前控制器的View的frame的情況下,然后運行的時候,發(fā)現(xiàn)控制器的Frame的高度y值會從導(dǎo)航條的位置64變化到0。

導(dǎo)致UITextView的frame也跟著一起移動。

這個問題本質(zhì)其實就是iOS7View被導(dǎo)航欄遮擋問題,于是經(jīng)過百度搜索到答案。特此下面復(fù)制拷貝 做個簡單的筆記:

self.navigationController.navigationBar.translucent = NO;

如果在iPad上用了split view,并且設(shè)置了UINavigationBar的background image,現(xiàn)象為狀態(tài)欄一直是一片漆黑

UINavigationController will alter the height of its UINavigationBar to either 44 points or 64 points, depending on a rather strange and undocumented set of constraints. If the UINavigationController detects that the top of its view’s frame is visually contiguous with its UIWindow’s top, then it draws its navigation bar with a height of 64 points. If its view’s top is not contiguous with the UIWindow’s top (even if off by only one point), then it draws its navigation bar in the “traditional” way with a height of 44 points. This logic is performed by UINavigationController even if it is several children down inside the view controller hierarchy of your application. There is no way to prevent this behavior.

意思就是UINavigationBar的高度會自行調(diào)整為44或者64,沒有確定的預(yù)測方法。而之前作為UINavigationBar背景的圖片是44高度的。最后換了張64高度,上面留了20px透明的圖片搞定

網(wǎng)友還有一種解決辦法

IOS7的視圖有個邊緣延伸的屬性:edgesForExtendedLayout,

其默認值是UIExtendedEdgeAll。

只要將其改成UIExtendedEdgeNone即可,要注意的是在IOS7以下版本會出現(xiàn)bug。

所以在UIViewController 的viewDidLoad里加上下面代碼就完美解決了這個問題

if( ([[[UIDevice currentDevice] systemVersion] doubleValue]>=7.0)) {

self.edgesForExtendedLayout = UIRectEdgeNone;

self.extendedLayoutIncludesOpaqueBars = NO;

self.modalPresentationCapturesStatusBarAppearance = NO;

}

總結(jié)

以上是生活随笔為你收集整理的ios 不被遮挡 阴影_IOS开发之Bug--iOS7View被导航栏遮挡问题的解决的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。