Ios Nativescript IPhone X-如何;隐藏“;主屏幕指示灯位于两次滑动后,可转到主屏幕
我使用的是Nativescript Angular(NS版本4.1),我试图实现一个要求,即用户需要向上滑动两次才能回家 新的IOS设备。很多手机游戏都有这个功能 我知道这与Ios Nativescript IPhone X-如何;隐藏“;主屏幕指示灯位于两次滑动后,可转到主屏幕,ios,xcode,nativescript,nativescript-angular,Ios,Xcode,Nativescript,Nativescript Angular,我使用的是Nativescript Angular(NS版本4.1),我试图实现一个要求,即用户需要向上滑动两次才能回家 新的IOS设备。很多手机游戏都有这个功能 我知道这与首选项显示或自动隐藏有关 视图控制器中的首选屏幕边缘延迟系统手势 有没有办法在Nativescript中访问这些方法? 或者只是设置一个home指示器,需要两次刷卡才能回家 任何帮助都将不胜感激,谢谢 存在允许覆盖iOS根视图控制器属性的开放。您必须实际覆盖首选屏幕边缘将系统手势延迟到UIDirectEdge。所有以及根据A
首选项显示或自动隐藏有关
视图控制器中的首选屏幕边缘延迟系统手势
有没有办法在Nativescript中访问这些方法?
或者只是设置一个home指示器,需要两次刷卡才能回家
任何帮助都将不胜感激,谢谢 存在允许覆盖iOS根视图控制器属性的开放。您必须实际覆盖首选屏幕边缘将系统手势延迟到UIDirectEdge。所有以及根据Apple,您还必须更新设置需要的家庭指示灯的更新日期
但如果您试图直接访问这些属性(例如this.page.ios.preferShomeIndicator AutoHidden=true
),则会出现错误TypeError:试图分配给只读属性。
这里讨论了如何复制控制器、修改属性并将其分配回所有者的解决方案
const UIViewControllerImpl = new page.Page().ios.constructor as typeof UIViewController;
const MyCustumUIViewController = UIViewController['extend'](Object.assign(
{},
// merge in the original methods
...UIViewControllerImpl.prototype,
// add additional instance method / property overrides here, such as ...
{
preferredScreenEdgesDeferringSystemGestures() {
console.log("This will be called from native!");
return UIRectEdge.All;
}
}
));
const performNavigation = frame.Frame.prototype['performNavigation'];
frame.Frame.prototype['performNavigation'] = function(navigationContext:{entry:frame.BackstackEntry}) {
const page = navigationContext.entry.resolvedPage;
const controller = (<typeof UIViewController>MyCustumUIViewController).new();
controller['_owner'] = new WeakRef(page);
controller.automaticallyAdjustsScrollViewInsets = false;
controller.view.backgroundColor = new color.Color("white").ios;
page['_ios'] = controller;
page.setNativeView(controller.view);
performNavigation.call(this, navigationContext);
}
const UIViewControllerImpl=new page.page().ios.constructor作为UIViewController的类型;
const MyCustumUIViewController=UIViewController['extend'](Object.assign)(
{},
//在原始方法中合并
…UIViewControllerImpl.prototype,
//在此处添加其他实例方法/属性重写,例如。。。
{
首选屏幕边缘延迟系统手势(){
log(“这将从本机调用!”);
返回UIRectEdge.All;
}
}
));
const performNavigation=frame.frame.prototype['performNavigation'];
frame.frame.prototype['performNavigation']=函数(导航上下文:{entry:frame.BackstackEntry}){
const page=navigationContext.entry.resolvedPage;
const controller=(mycustumuviewcontroller).new();
控制器[“所有者”]=新WeakRef(第页);
controller.automaticallyAdjustsScrollViewInsets=false;
controller.view.backgroundColor=新的color.color(“白色”).ios;
第[''u ios']=页控制器;
page.setNativeView(controller.view);
performNavigation.call(此,navigationContext);
}
我在这里找到了一个解决方法。谢谢你的解决方法,我确实尝试过,但没有成功。他说它与tns core合作-modules@3.4.0
我正在使用~4.0.0
而且我甚至不确定要将此代码放在哪个文件中,我尝试了main.ts
和app.component
。代码确实在运行,但我从未得到显示的“这将从本机调用!”
console.log。如果你有任何想法,请告诉我。再次感谢!