For WatchKit App, you can create multiple InterfaceControllers in Storyboard and draw view conversion connections intuitively like in iOS applications. Of course, we can also implement corresponding view switching and jumping through view controller code. In short, there are three forms of view conversion connections: 1. Push/Pop - Provides stack-based view control in Hierarchical form. Hierarchical means hierarchical view architecture. The effect is similar to the Navigation interface in iOS applications. It is mainly used for view conversion of navigation classes. First, there must be a root view controller. When the next level view is pushed into the stack and popped out by triggering dragging in Storyboard or using pushControllerWithNames: code, a <left arrow will be added in front of the title bar. Clicking it will return to the previous level view. You can also execute popController() code, and you can use popToRootController() to directly return to the root view. 2.Present - Similar to the Push method, it will jump to a Modal view. The difference is that the controller of the current view will be released and the didDeactivate method will be executed, but we can still click the title bar in the modal view or call the dismissController() method in the view controller code to reactivate the previous view. 3.Next page - Paginated view mode, multiple views are arranged horizontally and side by side. Swipe left or right to switch, with small dots at the bottom to mark. Now many iOS apps have this paginated navigation when they start, which is used to prompt operation methods or new functions. In Storyboard, hold down control and drag from view A to view B and select next page to establish this relationship. For details, please refer to the article "WatchKit Programming Guide: WatchKit Apps--Interface Navigation": The following is a summary of some common problems and their solutions: 1.Q: When the main controller is a paging view, the hierarchical view stack cannot be pushed; when the main controller is a hierarchical view, the paging view cannot be pushed. A: Page-based and Stack modes are mutually exclusive, so you must use a modal method to switch. When the main controller is a paging view, you can use the presentControllerWithName: method to correctly pop up a hierarchical view stack. When the main controller is a hierarchical view, you can use the
Method, and pop up a paging view consisting of multiple pages, you need to use
method. 2.Q: How to pass parameters between views? A: Use the context parameter to encapsulate the parameter object. If you need to pass the view controller delegate in push mode, you can refer to the article "WatchKit's Delegate and Context" that I translated before. 3. Q: I defined a context menu for ForceTouch, but when I switched views and activated the context menu and clicked it, an error message appeared saying that the view pointer was lost. A: Because you defined the context menu in awakeWithContext: in your code, and then popped it up modally, so the original view is destroyed after switching views and the menu content code cannot be called correctly. The solution is: I. Use push to switch views, so that the main view is stored in the view stack and the object is not destroyed; II. Still use modal to switch views, but put the context menu definition code in willActivate() function, so that the menu definition will be reloaded and will not be invalid. |
>>: Programmers are not bricklayers, they are writers
Since the development of China's Internet, in...
In recent times, many people have claimed to be d...
01 Content drives traffic The concept of "co...
As we all know, a job advertisement consists of t...
Today, Feng Chao, editor of Jimifeng Technology, ...
The latest market research data shows that Apple ...
In the first half of 2021, many new opportunities...
According to Reuters, Honda Motor said on June 21...
According to foreign media reports, people famili...
Nowadays, “two Weibo and one Douyin” have become ...
Brand promotion can greatly increase exposure by ...
Have you heard the story of A Chinese Ghost Story...
Recently, China New Car Assessment Program (C-NCA...
From my own perspective, I sorted out my understa...
Website promotion and marketing of pharmacies 1. ...