激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - IOS - iOS 13適配匯總(推薦)

iOS 13適配匯總(推薦)

2021-05-27 16:22仰望星空01 IOS

這篇文章主要介紹了iOS 13適配匯總,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧

隨著iphone 11的發布,ios 13適配也提上了日程,接下來就開發中升級ios13的手機可能出現的問題

xcode: 11.0
ios : 13.0

uiviewcontroller 模態彈出界面

viewcontroller.present(presentvc, animated: true, completion: nil)

在調用模態彈出視圖,會發現彈出的界面沒有全屏。如圖

iOS 13適配匯總(推薦)

通過多次的嘗試,發現在低版本里面不會發生這種情況(ios12及以下),于是我查閱了最新的開發文檔,發現了端倪,主要還是因為我們之前忽略了uiviewcontroller里面的一個屬性,即:modalpresentationstyle

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
defines the presentation style that will be used for this view controller when it is presented modally. set this property on the view controller to be presented, not the presenter.
 if this property has been set to uimodalpresentationautomatic, reading it will always return a concrete presentation style. by default uiviewcontroller resolves uimodalpresentationautomatic to uimodalpresentationpagesheet, but other system-provided view controllers may resolve uimodalpresentationautomatic to other concrete presentation styles.
 defaults to uimodalpresentationautomatic on ios starting in ios 13.0, and uimodalpresentationfullscreen on previous versions. defaults to uimodalpresentationfullscreen on all other platforms.
 
 
public enum uimodalpresentationstyle : int {
  case fullscreen
  
  @available(ios 3.2, *)
  case pagesheet
  @available(ios 3.2, *)
  case formsheet
 
  @available(ios 3.2, *)
  case currentcontext
 
  @available(ios 7.0, *)
  case custom
 
  @available(ios 8.0, *)
  case overfullscreen
 
  @available(ios 8.0, *)
  case overcurrentcontext
 
  @available(ios 8.0, *)
  case popover
 
  
  @available(ios 7.0, *)
  case none
 
  @available(ios 13.0, *)
  case automatic
}

通過查看api 可以看到,ios 13 新增一個:automatic類型,默認情況下就是這個所以才會彈出不是全屏的界面。如果我們想要修改為全屏的話

可以:presentvc.modalpresentationstyle = .fullscreen設置為全屏即可

kvc 限制

ios13以后已經不能肆無忌憚的通過 kvc來修改一些沒有暴露出來的屬性了。

*** terminating app due to uncaught exception 'nsgenericexception', reason: 'access to xxx's _xxx ivar is prohibited. this is an application bug'

我們常用的有

?
1
2
3
4
5
6
// uitextfield 的 _placeholderlabel
    let textfield = uitextfield.init()
    textfield.setvalue(uicolor.red, forkey: "_placeholderlabel.textcolor")
    
    /// uisearchbar 的 _searchfield
    [searchbar valueforkey:@"_searchfield"]

下面方法替換

?
1
2
3
4
5
///分別設置字體大小和顏色(富文本)
textfield.attributedplaceholder = nsattributedstring.init(string: "請輸入....", attributes: [nsattributedstring.key.foregroundcolor: uicolor.red], [nsattributedstring.key.font: uifont.systemfont(ofsize: 15)])
 
 /// uisearchbar 用 searchfield代替
bar.value(forkey: "searchfield") as! uitextfield

uisegmentedcontrol 默認樣式改變

默認樣式變為白底黑字,如果設置修改過顏色的話,頁面需要修改

uitabbar

如果之前有通過tabbar上圖片位置來設置紅點位置,在ios13上會發現顯示位置都在最左邊去了。遍歷uitabbarbutton的subviews發現只有在tabbar選中狀態下才能取到uitabbarswappableimageview,解決辦法是修改為通過uitabbarbutton的位置來設置紅點的frame

app啟動過程中,部分view可能無法實時獲取到frame

?
1
2
// 只有等執行完 uiviewcontroller 的 viewdidappear 方法以后,才能獲取到正確的值,在viewdidload等地方 frame size 為 0,例如:
 uiapplication.shared.statusbarframe

廢棄uiwebview

查看api可以看到:ios 2.0 到 ios 11.0
在12.0就已經被廢棄,部分app使用webview時, 審核被拒

?
1
2
3
4
5
6
@available(ios, introduced: 2.0, deprecated: 12.0, message: "no longer supported; please adopt wkwebview.")
open class uiwebview : uiview, nscoding, uiscrollviewdelegate {
    .........
    .........
    .........
}

cncopycurrentnetworkinfo

ios13 以后只有開啟了 access wifi information capability,才能獲取到 ssid 和 bssid wi-fi or wlan 相關使用變更
最近收到了蘋果的郵件,說獲取wifi ssid的接口cncopycurrentnetworkinfo 不再返回ssid的值。不仔細看還真會被嚇一跳,對物聯網的相關app簡直是炸彈。仔細看郵件還好說明了可以先獲取用戶位置權限才能返回ssid。
注意:目本身已經打開位置權限,則可以直接獲取

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
- (nsstring*) getwifissid {
  if (@available(ios 13.0, *)) {
    //用戶明確拒絕,可以彈窗提示用戶到設置中手動打開權限
    if ([cllocationmanager authorizationstatus] == kclauthorizationstatusdenied) {
      nslog(@"user has explicitly denied authorization for this application, or location services are disabled in settings.");
      //使用下面接口可以打開當前應用的設置頁面
      //[[uiapplication sharedapplication] openurl:[nsurl urlwithstring:uiapplicationopensettingsurlstring]];
      return nil;
    }
    cllocationmanager* cllocation = [[cllocationmanager alloc] init];
    if(![cllocationmanager locationservicesenabled] || [cllocationmanager authorizationstatus] == kclauthorizationstatusnotdetermined){
      //彈框提示用戶是否開啟位置權限
      [cllocation requestwheninuseauthorization];
      usleep(50);
      //遞歸等待用戶選選擇
      return [self getwifissidwithcallback:callback];
    }
  }
  nsstring *wifiname = nil;
  cfarrayref wifiinterfaces = cncopysupportedinterfaces();
  if (!wifiinterfaces) {
    return nil;
  }
  nsarray *interfaces = (__bridge nsarray *)wifiinterfaces;
  for (nsstring *interfacename in interfaces) {
    cfdictionaryref dictref = cncopycurrentnetworkinfo((__bridge cfstringref)(interfacename));
 
    if (dictref) {
      nsdictionary *networkinfo = (__bridge nsdictionary *)dictref;
      nslog(@"network info -> %@", networkinfo);
      wifiname = [networkinfo objectforkey:(__bridge nsstring *)kcnnetworkinfokeyssid];
      cfrelease(dictref);
    }
  }
  cfrelease(wifiinterfaces);
  return wifiname;
}

同意打印:如下

?
1
2
3
4
5
6
7
8
9
10
11
network info -> {
bssid = "44:dd:fb:43:91:ff";
ssid = "asus_c039";
ssiddata = <41737573 5f633033 39>;
}
不同意
network info -> {
bssid = "00:00:00:00:00:00";
ssid = wlan;
ssiddata = <574c414e>;
}

持續更新中…

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。

原文鏈接:https://blog.csdn.net/weixin_38735568/article/details/100850524

延伸 · 閱讀

精彩推薦
  • IOSiOS中UILabel實現長按復制功能實例代碼

    iOS中UILabel實現長按復制功能實例代碼

    在iOS開發過程中,有時候會用到UILabel展示的內容,那么就設計到點擊UILabel復制它上面展示的內容的功能,也就是Label長按復制功能,下面這篇文章主要給大...

    devilx12792021-04-02
  • IOSiOS開發技巧之狀態欄字體顏色的設置方法

    iOS開發技巧之狀態欄字體顏色的設置方法

    有時候我們需要根據不同的背景修改狀態欄字體的顏色,下面這篇文章主要給大家介紹了關于iOS開發技巧之狀態欄字體顏色的設置方法,文中通過示例代碼...

    夢想家-mxj8922021-05-10
  • IOSiOS自定義UICollectionViewFlowLayout實現圖片瀏覽效果

    iOS自定義UICollectionViewFlowLayout實現圖片瀏覽效果

    這篇文章主要介紹了iOS自定義UICollectionViewFlowLayout實現圖片瀏覽效果的相關資料,需要的朋友可以參考下...

    jiangamh8882021-01-11
  • IOSiOS實現控制屏幕常亮不變暗的方法示例

    iOS實現控制屏幕常亮不變暗的方法示例

    最近在工作中遇到了要將iOS屏幕保持常亮的需求,所以下面這篇文章主要給大家介紹了關于利用iOS如何實現控制屏幕常亮不變暗的方法,文中給出了詳細的...

    隨風13332021-04-02
  • IOSiOS中MD5加密算法的介紹和使用

    iOS中MD5加密算法的介紹和使用

    MD5加密是最常用的加密方法之一,是從一段字符串中通過相應特征生成一段32位的數字字母混合碼。對輸入信息生成唯一的128位散列值(32個字符)。這篇文...

    LYSNote5432021-02-04
  • IOSiOS中滑動控制屏幕亮度和系統音量(附加AVAudioPlayer基本用法和Masonry簡單使用)

    iOS中滑動控制屏幕亮度和系統音量(附加AVAudioPlayer基本用法和

    這篇文章主要介紹了iOS中滑動控制屏幕亮度和系統音量(附加AVAudioPlayer基本用法和Masonry簡單使用)的相關資料,需要的朋友可以參考下...

    CodingFire13652021-02-26
  • IOS詳解iOS中多個網絡請求的同步問題總結

    詳解iOS中多個網絡請求的同步問題總結

    這篇文章主要介紹了詳解iOS中多個網絡請求的同步問題總結,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧...

    liang199111312021-03-15
  • IOSiOS開發之視圖切換

    iOS開發之視圖切換

    在iOS開發中視圖的切換是很頻繁的,獨立的視圖應用在實際開發過程中并不常見,除非你的應用足夠簡單。在iOS開發中常用的視圖切換有三種,今天我們將...

    執著丶執念5282021-01-16
主站蜘蛛池模板: 日本不卡一二三区 | 九色中文字幕 | av在线一区二区三区四区 | 五月婷婷第四色 | 国产日韩中文字幕 | av7777777| 日本成人高清视频 | 久久99久久99精品 | 国产色妞影院wwwxxx | 爱射av| 成人久久久久久久久久 | 久久艹逼 | 久久线视频 | 欧美成人亚洲 | 国产精品久久久久久久午夜片 | 久久99国产精品免费网站 | 国产精品成人亚洲一区二区 | 99久久免费看精品国产一区 | 国产精品久久久久免费视频 | 国产99久久久久久免费看农村 | 久草在线综合 | 午夜视频你懂的 | 欧美人成在线 | 免费黄色小网站 | 1区2区3区在线观看 欧美特黄a | 污版视频在线观看 | 中国漂亮护士一级a毛片 | 香蕉在线播放 | 色操网| 成人超碰 | 91成人午夜性a一级毛片 | 国产成人综合在线观看 | 久久国产精品久久精品国产演员表 | www.777含羞草 | 久久久一区二区三区精品 | 毛片视频网站 | 88xx成人精品视频 | 国产精品美女一区二区 | 国产小视频一区 | 久久久久国产成人精品亚洲午夜 | 欧美成人高清在线 |