Swift UI with MVVM architecture navigating screens in complicated apps - ios

How can I navigate from one screen to another screen in Swift UI app , I am trying to implement MVVM architecture in my app and I have more than 20 screens so NavigationLink is not suitable in my case .
Thanks in advance .

I quite understand your problem, previously we had a central navigation controller (UINavigationController) we could call it anywhere and do a push or pop, but now only the current view can do a navigation using NavigationLink, I faced the same problem and the solution was to implement an UINavigationView in a sigleton and call it anywhere I want to push a view like MyNavigation.push(UIHostingController(rootView: NextView())).
Anyways, I think this approach is wrong because a new UIHostingController is created for every screen, so we lose some of the optimizations introduced by SwiftUI. If you really want to use the powerful features of SwiftUI I recommend you to redesign your app to adapt to SwiftUI capabilities

Related

How to smoothly translate view in iMessage extension in iOS 10?

I have issue when I try to push view controller in willTransitionToPresentationStyle:. The view was blinking for a split second before it fully expanded. It might be a small glitch or bug since iOS 10 and Xcode 8 are still in beta. But when I manually requested to change presentation style to MSMessagesAppPresentationStyleExpanded by calling requestPresentationStyle: after I push view controller, it went to expand mode more smoothly. Does anyone have similar issue?
I have had similar problems with transitions in iMessage apps. I think this should improve considerably when iOS 10 and Xcode 8 come out of beta, but for now we have to deal with Xcode's bugs.
There's a few things I've done to make this look better. Inside my extension I have a method that checks the presentation style every time the view changes. This method manages two different UIs - one for MSMessagesAppPresentationStyleExpanded and one for MSMessagesAppPresentationStyleCompact. This method hides and shows specific views accordingly. In my compact UI I have a button that allows the user to expand the interface by clicking it (this is basically the same as clicking the up arrow at the bottom right of the screen).
I've noticed that if you let the user expand the messages app after the view has been loaded for a while the transitions are much smoother and less buggy. Not sure why this is the case, but you should give it a try. Also, I've found segues to be extremely buggy, so that's why I went with keeping everything on one view controller.

ios: How to implement navigation of a slide out menu?

So far I have been working with NavigationController. It's great for hierarchical navigation.
But, how do I implement a slide out menu that exists on every page, and is able to jump to any page?
Not caring about the design, I guess we would need to load/unload xib files manually to the superview?
Is this a good practice?
Probably the best way to get you going is to implement/check some of the already developed open source solutions.
Please, check out:
MMDrawerController which is a simpler version
and MSDynamicsDrawerViewController which is a bit more complicated (to develop) because it uses iOS 7 Dynamics.
Cheers.

App starting as Single view and proceed to tabbar application

I am about to create an xcode iphone app which will lauch initially as a single view ( something like login and settings screens ) and then proceed to a tabbed bar application with multiple tabs .
how to do this -
should i create two differnet projects one single view and one tabbed application ?
and is it possible to roll two projects into one single app ?
or is there just another easier way. I have xcode 4.3 and planning to use storyboard insteaod of XIBs
rgds,
sumit
Do not start with two projects, as you'll have an incredibly difficult time integrating them into one app. This is pretty simple, but you do need to learn the basics of view controllers.
Use Storyboards, and start with a single view app, maybe inside a navigation controller. Then do a transition to a tabbed view controller.
Upgrade to Xcode 4.6.3 or 5. Look at Apple's template apps for a tabbed application and a single view app to see how the storyboards look. Then copy the storyboards in one to the other, and link them up. This is definitely possible and straightforward, but you do need to understand how each view controller works with the others.
I also faced same situation once. I made a project as single view based app. without storyboard (since I was required to build compatible apps with iOS 4.3).
Made login screen as main view controller.
On login, I presented tab viewcontroller modally.
On sign out, I dismiss tab controller and return back to login screen.
If you have any queries, just ask it :)

Gmail iOS Modal View Transition

Just wondering if anyone have tried to replicate the transition that is used for presenting modal views in Gmail iOS? It looks darn gorgeous and refreshing from the pop up from bottom animation.
Pretty sure you're referring to the push-back transition when displaying the modal view controller? If so, then it's the one that the National Geographic Park Guides app first introduced and someone has released their replica of it over on Github. This one is only a partial screen modal, but could be modified to mimic the full view that the Gmail app does.
How about using this? Detailed animation, there is a need to develop a little more.
https://github.com/ucu072/HCPushBackAnimation
I created a UIViewController category to mimic this type of modal animation. It is called MFFadeBackModalAnimation. It wraps around the native API for presenting and dismissing view controllers so it should integrate well with your existing app.

iOS:Switching between views using UINavigationBarController

First of all, I am using XCode 4.2 and I am not using storyboards. I need to make an application with 2 views.
First view will contain a button and a navigation bar, the button's IBAction should only go to the second view, and from the secondview you should be able to go back to the first view via the Navigationbar.
My problem is the navigation controller / navigation bar, how do I set that up ?
I know that it would be smart using the singleView app and then add a navigation controller, the problem is that I dont know how to set it up in the code.
I have searched for similar problems on the internet, and I keep getting into posts where they use another SDK or using an older xcode etc.
What I do know is how to make the button, actions and delegation.
Anyone out there who is sitting with the one and only tutorial I am missing or can tell me how to do it ?
Thank you
Use the Master-Detail Application template. Ignore the stuff for tables, it has navigation stack implemented in it. By deleting the tables, you should be pretty much left with what you are after.
You should go to http://developer.apple.com/, search for UINavigationController, click on UINavigationController Class Reference, then look at one of the linked sample code projects there.
if you really want to learn how to implement it from scratch (and not depend on the master-detail template), i highly recommend the following resources:
the apple documentation on UINavigationController
the solutions from the big nerd ranch iOS Programming guide (particularly the Homepwner example)
also found this tutorial in a quick google search, but haven't fully vetted it in xcode 4.2 (there will likely be small differences in how you have to go through the steps).

Resources