Cannot use TabView on SwiftUI, WatchOS - swift

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.

Related

Custom, swipe up, navigation on every page xcode

New to xcode so I am not quite understanding views and view controllers.
I want a simple 3-4 page app with swipe up navigation, similar to this question:
How to mimic iOS 10 maps bottom sheet
How would I implement this on every page instead of hard coding into each one?
If I decided to add more pages that would become tedious and inefficient.
I have used Ionic 2 and you simply make an outlet for all your views to go into, with your navigation surrounding it.
I saw containers in xcode, but that seems to be more difficult then a push/pop navigation.
What is the best way to implement this in the storyboard?
Yes, I have no code, but the story board does not need code
How would I implement this on every page instead of hard coding into each one?
If you know how to do it, you should never need to copy it to each page. You could make a base class or (even better) a protocol with extension that implements it.
You could also make a swipe-up view that puts gestures into its parent view when it's added.
If you do that, you could add the storyboard directly (add a UIView, change its class to yours)

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

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.

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 can I show iAds throughout entire app?

First of all, it seems frowned upon to have my iAds showing throughout my entire app. Is it a bad thing to show them throughout the whole app? Why/why not?
And my real question is, is it possible to add iAds to the whole app? I am thinking I could add it in application:didFinishLaunchingWithOptions but I'm not sure exactly how to keep it as the topmost view. Has anyone done this before? Any suggestions?
Thanks!
You First Question is a topic for discussion, so I am not getting into that.
For your real question, You can have one main/container ViewController and have one placeholder for child ViewController and one placeholder for iAds. You actual ViewControllers can be added to the main view controller using ViewController containment api. You can find more about ViewController containment here: Creating Custom Container View Controllers

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.)