Is it possible to use watchOS 3 vertical detail paging with a page-based interface? - apple-watch

I am looking to update my watchOS app with the latest watchOS 3 improvements, but I am running into an issue getting the new WKInterfaceTable vertical paging to work. It seems that vertical detail paging requires you to use the hierarchical navigation structure throughout your app.
When I remove all but 1 of my InterfaceControllers and use a push segue from my tables, the paging works as expected. However, if I instead use a push segue from within a page-based interface, nothing happens. When I switch that to a modal segue, the segue itself works but the vertical paging is not enabled then.
Any solutions other than completely switching my apps navigation to get to use this nice watchOS 3 improvement?

According to couple WWDC 2016 videos like Quick Interaction Techniques for watchOS
and Architecting for Performance on watchOS 3 you need to
Enable the Vertical Detail Paging checkbox in your table inspector.
Use segues from your table to detail interface.
Make sure the detail interface fits screen height.
So yes, you have to use hierarchical navigation structure (more precisely tables) to take advantage of the new detail paging API.

Related

Cannot use TabView on SwiftUI, WatchOS

Is there a way to use TabView using SwiftUI on WatchOS?
I've seen most of the WWDC talks and they don't mention it for WatchOS. Moreover, in the apple documentation it is not enumerated under SDK's.
Whenever I try to add it to a WatchOS project I get the following error:
'TabView' is unavailable in watchOS
Or is there a good way to replicate the desired TabView ?
I want something similar to this:
Two different pages that are changed simply by swiping horizontally.
If you want a page based navigation (swipe left/right between view controllers) in your app you simply add another WKHostingController to your project's storyboard. Connect the two hosting controllers by creating a segue between them. The segue is what determines how you navigate between controllers.
This page has a good guide on how to do it: https://www.techotopia.com/index.php/A_WatchKit_Page-based_Navigation_Tutorial
Just keep in mind that you want to add another hosting controller to the storyboard, not anything else.
I have not found a way to do this programmatically in SwiftUI, this seems like the only way to do it for now.
It's now available starting with watchOS 7: https://developer.apple.com/documentation/swiftui/tabview.

Segues vs addSubView on iOS

What are the advantages of using segues vs managing view controllers and subviews like we did pre-iOS 5.
Pre iOS 5 I might:
Build XIB files for my various Views then do something like [myVC.view addSubView:newVC.view];
vs Segues
You get the advantage of working with storyboards and the functionality of passing data between view controllers (which was easily accomplished pre iOS 5 in multiple ways).
So to me it looks like the only advantage of using segues is that you can use storyboards and pass data between VCs.
Is that right? Or are there other advantages?
one of the down sides that can be added to Kunai Balani's answer is that it makes working with a team with version control more difficult if many people are working on the same storyboard. my svn gets really confused when 2 people make an edit on the storyboard.
if you are not working with a team then you can disregard this disadvantage
There are several advantages :
1) Communication. Storyboard (and thus use of segues) is makes it easy to understand the flow of your application. This gives other developers an ease of understanding of the structure of view controllers without looking through any code or debugging.
2) You save time by using segues. Just imagine doing push and pop everywhere all around your application. If you need to change transition (lets say modal transition animation style) for all your view-controllers you have to go and search for each and every view controller then modify it. With storyboard all of them are at one place. It's easy to modify their transition style with just modifying one attribute.
3) Ease of debugging. Lets say your application crashed during a push in navigation controllers. With story board you get the identifier for your segue which caused this. No need to follow stack trace across your UINavigation Controller.

How to make a horizontal scrollable UITabBar in iOS?

The UITabBar in my app consists of 10+ items, but the width is enough to put all 10+ items.
How to make a horizontal scrollable UITabBar in iOS ?
Thanks.
You'll have to roll your own to at least some extent.
What might work, would be to create a UITabBar view (not the controller) and embedded it in a UIScrollView. You could then use that in place of your regular Tab Bar control by adding it to your TabBarController.view/tabBarView or something. Of course you'd have to play around to get it to look right, and I'm not sure if just setting the view to something wider will actually make it display more items or not.
Of course, for best results you'd probably want to do something entirely custom.
From Apple's Developer Portal:
If you add more than five items to the viewControllers property, the tab bar controller automatically inserts a special view controller (called the More view controller) to handle the display of the additional items.
Source
Seems like you will need to make a custom tab bar.
They also said this in the next paragraph:
Although the tab bar view is a key part of your tab bar interface, you do not modify that view directly.
You might be breaking Apple's design guidelines by doing this.
You can certainly go and create a custom class of the UITabBar (embedding it into a scrollview etc.)..but why re-invent the wheel? After searching around I found several third-party classes already created that work well and are easy to use and highly customizable..In order of personal preference:
M13InfiniteTabBar -
https://github.com/Marxon13/M13InfiniteTabBar
JSScrollableTabBar -
https://github.com/jasarien/JSScrollableTabBar
InfiniTabBar -
https://github.com/iosdeveloper/InfiniTabBar

Creating custom menu at top like Real Simple Recipes does

I want to create tabbar controller placed at the top like Real Simple Recipes in iPad has done. I suspect that it is not UITabBarController as I have tried so many ways to place tab bar on the top by setting its view frame as
self.tabBarController.tabBar.view.frame = CGRectMake (0,0,768,self.tabBarController.tabBar.view.frame.height);
But it is not working.
Is it custom tabbar controller created or it is managed manually ? Any sample code or direction would be appriciated.
You want to make a custom view switcher of your own. This blog post has a nice tutorial for doing so. It uses a segmented control to do the switching, but you could adapt it to use a row of buttons if you needed a custom look.
(If you are OK requiring iOS 5, this gets easier with the view controller containment APIs, and it'd be a completely different implementation to the one suggested in that article.)

UISplitViewController for iphone

I want to create an iPhone (not iPad) app with a split screen view that shows two view controllers on the same screen, one on the left and one on the right of the screen (landscape only).
Is there a way to make UISplitViewController work for iPhone, or is there an open source library i can use to achieve this look?
As said, you can not use a split view controller. However, I dont think you need it anyway. Its a little cumbersome and restrictive.
You can achieve the effect of the split view controller easily using subviews. (Try to avoid using multiple view controllers as this is generally bad practice).
Create two custom views and ad them as sub views to the main view. Look at their auto resizing properties. Try to use interface builder. Show / hide you side view when the user rotates.
UISplitViewControllers aren't that useful - you can mimic their effectes easily.
There is no way you can achieve this using the UISplitViewController class. If you take a look at the Apple reference documents it clearly states that the UISplitViewController is an iPad-specific viewcontroller.
Note this point
If you are developing a universal application, though, be sure not to create and use these controllers when your application is running on an iPhone or iPod touch.