Существует открытый запрос функции , позволяющий переопределить свойства контроллера корневого представления iOS. Вы должны переопределить preferredScreenEdgesDeferringSystemGestures
на UIRectEdge.All
, а согласно документации Apple вам также необходимо обновить setneedsupdateofhomeindicator
.
Но если вы попытаетесь получить доступ к этим свойствам напрямую (например, this.page.ios.prefersHomeIndicatorAutoHidden = true
), это выдаст вам ошибку TypeError: Attempted to assign to readonly property.
Это обходной путь, обсуждаемый здесь , где вам нужно скопировать контроллер, изменить свойство и назначить его обратно владельцу.
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);
}