简体   繁体   English

在watchOS中,是否可以显示没有导致根视图的状态栏按钮的视图?

[英]In watchOS, is it possible to display a view without a status bar button that leads to the root view?

I would like to have a similar navigation structure to the built-in Workout app in watchOS. 我想拥有与watchOS中内置的Workout应用类似的导航结构。 I have a list of tennis rules formats, analogous to workout types in the Workout app. 我有一个网球规则格式列表,类似于“锻炼”应用程序中的锻炼类型。 Tapping one starts a match in a new interface controller. 轻按一个将在新的接口控制器中开始匹配。 In WatchKit, as far as I know, I can only push an interface controller or present one. 据我所知,在WatchKit中,我只能推送一个接口控制器或提供一个接口控制器。 Both approaches risk the user canceling the match earlier from the top left chevron or tapping the status bar in a presented modally. 两种方法都存在使用户冒着从左上方人字形提前取消匹配或轻敲所呈现的模式中的状态栏的风险。

The workout does not have that limitation during a workout session, instead, the user ends the workout from switching pages in its page-based navigation. 在锻炼期间,锻炼没有该限制,而是由用户在其基于页面的导航中切换页面来结束锻炼。 Does SwiftUI with its fully programmatic way of watchOS app development allow for accomplishing this? SwiftUI以其完整的watchOS应用程序开发方式来实现这一目标吗?

Below is the initial view of the Workout app 以下是“锻炼”应用程序的初始视图

在此处输入图片说明

Selecting a workout switches to a screen where the top left title isn't tappable, which is what I'd like to accomplish (the initial view is completely hidden and does not show when you swipe between the three pages) 选择锻炼时,切换到无法点击左上角标题的屏幕,这就是我要完成的操作(初始视图完全隐藏,在三页之间滑动时不会显示)

在此处输入图片说明

I think you need to take a look at reloadRootPageControllers() 我认为您需要看看reloadRootPageControllers()

See https://developer.apple.com/documentation/watchkit/wkinterfacecontroller/2868441-reloadrootpagecontrollers 参见https://developer.apple.com/documentation/watchkit/wkinterfacecontroller/2868441-reloadrootpagecontrollers

The basic idea appears to be that you are replacing the current interface controllers with the named ones listed in this method. 基本想法似乎是用此方法中列出的命名控制器替换当前的接口控制器。

WKInterfaceController.reloadRootPageControllers(withNames: ["workout","nowPlaying"], contexts: [workoutToRecord], orientation: WKPageOrientation.horizontal, pageIndex: 0)

In my Interval Training app I call this method once a user has selected their workout. 一旦用户选择了锻炼方式,我就会在我的Interval Training应用程序中调用此方法。 and this interface is then replaced with workout interface and now playing page. 然后此界面将替换为锻炼界面和正在播放的页面。

锻炼选择页面

You will note that there is no back button for them to accidentally return to the workout select screen. 您会注意到,没有可让他们意外返回到锻炼选择屏幕的后退按钮。

跑步锻炼

Hope that helps. 希望能有所帮助。

Maybe you need to modify your view with: 也许您需要使用以下方法修改视图:

  .navigationBarBackButtonHidden(true) 

Did you try that? 你尝试过吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM