随着iphone 11的发布,ios 13适配也提上了日程,接下来就开发中升级ios13的手机可能出现的问题
xcode: 11.0
ios : 13.0
uiviewcontroller 模态弹出界面
viewcontroller.present(presentvc, animated: true, completion: nil)
在调用模态弹出视图,会发现弹出的界面没有全屏。如图
通过多次的尝试,发现在低版本里面不会发生这种情况(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>;
}
|
持续更新中…
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持快网idc。
相关文章
- 64M VPS建站:能否支持高流量网站运行? 2025-06-10
- 64M VPS建站:怎样选择合适的域名和SSL证书? 2025-06-10
- 64M VPS建站:怎样优化以提高网站加载速度? 2025-06-10
- 64M VPS建站:是否适合初学者操作和管理? 2025-06-10
- ASP.NET自助建站系统中的用户注册和登录功能定制方法 2025-06-10
- 2025-07-10 怎样使用阿里云的安全工具进行服务器漏洞扫描和修复?
- 2025-07-10 怎样使用命令行工具优化Linux云服务器的Ping性能?
- 2025-07-10 怎样使用Xshell连接华为云服务器,实现高效远程管理?
- 2025-07-10 怎样利用云服务器D盘搭建稳定、高效的网站托管环境?
- 2025-07-10 怎样使用阿里云的安全组功能来增强服务器防火墙的安全性?
快网idc优惠网
QQ交流群
-
2025-05-27 44
-
2025-05-25 51
-
2025-06-04 107
-
2025-06-04 72
-
YII中Ueditor富文本编辑器文件和图片上传的配置图文教程
2025-05-29 56


