Basically what I want to do is depicted in the image below:
However this only loads the middle and third interface, the first is hidden both from swiping onto and in the circle indicators at the bottom.
I'd like to be able to load the second interface and swipe left for the first and swipe right for the third. Is there a way to achieve this?
Building my first Apple Watch app over here :)
Looks like there is a concept of UINavigationController-ish behaviour built into the WKInterfacesController.
Take a look at: pushControllerWithName(_:context:)
And from some docs I found here:
Hierarchical. This style is suited for apps with more complex data models or apps whose data is more hierarchical. A hierarchical interface always starts with a single root interface controller. In that interface controller, you provide controls that, when tapped, push new interface controllers onto the screen.
EDIT:
Looking into this some more. WatchKit is currently very limited by the looks.
The best solutions I could come up with was to add the three InterfaceController, with segues is between. Left -> Main -> Right.
Then assign a custom SKInterfaceController for Main:
class InterfaceController: WKInterfaceController {
override init() {
super.init()
becomeCurrentPage()
}
}
This creates an annoying animation in the beginning where you will see "Left" on start and how "Main" is animated pushed in. I don't see any better way to do this at this early stage of WatchKit.
The placement of the ViewControllers have no real "physical" meaning.
A segue (the arrows) simply defines a way to navigate from "this" ViewController to another one.
http://www.raywenderlich.com/81880/storyboards-tutorial-swift-part-2
It is possible to create as many segues from one ViewController to other ViewControllers as needed. You can name these segues, and trigger the one you want from storyboard send events or code for specific events (like swipe gestures).
To get the animation of actually sliding the view to the left would require a custom transition:
http://mathewsanders.com/animated-transitions-in-swift/
Related
I am making an app that has multiple view controllers that has a side view that you can go to navigate to each one, etc. I have everything set up and you can navigate to the side view by swiping from left to right to revealViewController, and that works splendid; however, what I would also like as well is to have a button that looks like 3 rectangles (not important to this, as I already designed the button) like on most apps, that you click and it would take you to that side view as if you where swiping like I have it set up right now. Does anyone know how to do this? I know it's pretty easy, but I am not quite sure.
An example of what I am trying to do, is in the Chase Mobile App. Even though this is a function that is in MANY different apps.
This is EXACTLY what I am trying to do in the example/image above
All help is gladly appreciated!!
I need to have that button open up the side menu just like this. Right now I have it were you slide from one side to the other to get this.
Please try this code to toggle the sideview appear and disappear as :
[self.revealViewController revealToggleAnimated:YES];
and
-(void)backButtonPressed {
[self.revealViewController rightRevealToggleAnimated:YES];
[self.navigationController popViewControllerAnimated:YES];
}
This is called a hamburger menu (or sidebar menu) and is typically frowned upon for iOS design. There are a number of reasons for this, but they are still used in many applications. Basically, they hide links and information from the user that should be quickly accessible.
Disney recently recreated the navigation in their Disney World app. Previously they used this method to navigate the app, but they changed it up pretty well. I personally like the change and that they were able to fit a large amount of information and features into their app without a sidebar.
While I don't recommend using this design, it is a great method to learn if only to better understand making custom views. There are many tutorials that will help you set this up online. A good example is at Appcoda.
Basically, you will need a root view controller with two views in it: the menu and the content. You will switch the content view controller with the view that is selected and active in the menu. You can show and hide the menu a number of ways, but one of the easiest is to move the menu left or right to place it in the frame or out of the frame. The tutorial linked above will get you pretty far. I would have gone into more detail, but there are so many resources regarding this that I don't see the point in copy/pasting it here.
What I ended up doing was from each tableView cell, instead of connecting it straight to the view I want it to show when you click that table cell, I had it go to a navigationaController with a segue (reveal view controller push controller) and then from that NavigationController I connected it to the view that I wanted it to display and connected it to that view controller by having a segue (root view controller), and then having the button in each view, and in each of the files .swift for those view controllers I connected the button up as you normally would, and for the code inside of the ViewDidLoad I have "menuBars.target = self.revealViewController()" and "menuBars.action = #selector(SWRevealViewController.revealToggle(_:))"
I want to display a UIViewController this way, that is: an upper viewcontroller slides out with a left-to-right animation and the lower one displays. Then, when you click the left button, this viewcontroller covers the other one again.
This is a very common UX pattern and I see lots of people doing it with third party components (eg. SWRevealViewController).
The question is: if I don't want to do it with a third party library, how can I do it?
IMO: Apple has stated that it's more of a design anti-pattern and appeal to popularity shouldn't be considered a good argument for this kind of design.
What you're looking for is a UIViewController containment and transitioning. Create a UIViewController class that accepts a, say, menuViewController (the lower one in your case) and an array of view controllers that can be displayed by tapping menu items.
Grab all the titles from the collection of view controllers and display them in menu view controller. Next by tapping the items in menu just use
- transitionFromViewController:toViewController:duration:options:animations:completion:
method for animating the transition between chosen view controllers.
It not so trivial to make, that's why people suggest to use some 3rd-party library.
But basically you want to create container view controller, add there your menu and main view controller above it and handle gesture recognition.
I have a textfield on the view controller. I want to populate the form after user taps the textfield. here is the animation which I want to implement
I want to know first did this app using two controllers. or it just using one controller in which it hides the form and open the next form after hiding first one. lets say if its using two controllers how can I open the second controller with animation like this image and also go back to 1st controller with animation.. at the moment I am simply opening a 2nd controller with default animation
func textFieldShouldBeginEditing(textField: UITextField) -> Bool {
self.navigationController!.pushViewController(self.storyboard!.instantiateViewControllerWithIdentifier("LoginViewController") as UIViewController, animated: true)
return false
}
The way they use it is very rather complex in terms of graphics but this more or less it:
1-They use two different view controllers, as should any good, organized programmer.
2-They then define a custom segue that performs the transition from to the other. The custom segue also takes care of animating the transition. Now I speak from experience when I say this: the whole modal segue animation framework is a pain, but it the only way to get those custom segue transitions working right. The way it happens is, you will overlay your second view controller on top of the first one, and then tell a custom animator what to do with individual elements and their frames, using that animator for your segue -- in this case squishing those buttons and expanding those two text fields.
As a full fledged beginner guide I may recommend: http://netsplit.com/custom-ios-segues-transitions-and-animations-the-right-way
I may also advise that the little tutorials out there that simply create a custom segue and animate the views before calling presentViewController: are very tempting but you will spend a good amount of time dealing with bugs, time wasted in the end because it will never be perfect.
I have made various attempt to go storyboard only and limit my code when it comes to UI. Everytime I was getting stuck and reverting back to code. Since the release of XCode 6 and the new iPhone that have multiple screen sizes it make more sense that ever to go Storyboard only.
This time I am stuck on the following scenario. I want to create a custom search view controller that will have 2 states:
Search State. It will prompt the user for a keyword to search.
Result State. It will display the results to the user.
I am aware that this can be accomplished using the UISearchController, but the customer wants to customise the behaviour. Currently I have two view controllers and a push/show segue between them. I would like to replace that with one view controller and animate the display of the results.
Is there any way that storyboard can accomplish that. I am thinking of creating two view controllers (in storyboard) with different layouts. Both will be linked on the same class. I could create a segue between them, but then I will lose all the variable stored inside them and will not be able to animate between them.
On the transition between the two states some UI elements will be hidden and some others will be moved. I would like that to be animated.
I know how to do that in code without using storyboard, but then I will have to cover all different screen scenarios. I hope there is an alternative way.
You can do this with two view controllers, and set a segue between them. The trick is that the animation bit will have to be done in code, unless you write a custom UIStoryboardSegue to handle the animation.
I Have interesting question.
I have two screens, I need that would be the third screen elements (buttons, label) are static and do not change when you move from one screen to another. .
So MAIN DISPLAY 1 will be change, DISPLAY 2 too , but button and others(label for example) need be static.
Big Thanks for all help, sorry i don't have any code with this problem. Because i don't know how this make...
Ok, so if you have a UI that won't change it's content you have to consider the following:
If the user can navigate from one screen to another, then you will have to create multiple view controllers(it can be done in other ways but this is the easiest and best way to doit) that will have their own UI, that can be easily created in storyboards like this:
Create a new project that use storyboars (you can use the Xcode templates that support your needs)
In your generated storyboard, drag and drop a new UINavigationController, and in the Attributes inspector check the Is initial view controller
Drag another UIViewController into your storyboard, select your navigation controller, hold right click and drag to the newly added view controller, a popup will appear and from that popup select root view controller. Now the newly added view controller will be the first view that the app will display. On this view controller add your UI elements (buttons, labels, etc). If you want another screen to be shown when a user taps on a button, drag another view controller and select the button from which you want to display the next screen, hold right click drag to the newly added view controller, from the popup select push. Now when the user tap on the button the next view controller will be shown and as a bonus because you use iOS, the system will create a back button so that you can go back to your first view controller.
Ok, this is the a basic tutorial from which you can start and expand, but for that you will have to read more, spend nights on google/SO to find solutions, you will learn apple docs by heart and other things that are required so that you can be a great iOS developer.
My the iOS force be with you and Steve Jobs watch your steps.
This is off the top of my head:
you could put a view into your uiwindow and place your static elements there, and then give a transparent background to display1 and display2. then you can have the two displays forward their touches to the background elements to have actions on the buttons. im sorry i dont have any code, but i never tried that ;)
A much better way is to instantiate your ViewController like so:
this.NavigationController.PresentModalViewController (StaticViewController.staticViewController, true);
Then inside your instantiated View Controller you setup a static variable that holds that instance of the View Controller:
public static StaticViewController staticViewController;
When the Static View Controller fires up for the first time:
staticViewController = this;
Now in the future when you fire up the Static View Controller (from wherever in your app) you can check to see if the StaticViewController.staticViewController variable is null or not.
Use simple if else logic to load it up accordingly:
if (StaticViewController.staticViewController == null) {
StaticViewController.staticViewController staticViewController = this.Storyboard.InstantiateViewController ("StaticViewController") as StaticViewController;
this.NavigationController.PresentModalViewController (StaticViewController.staticViewController, true);
} else {
if(!StaticViewController.staticViewController.IsBeingPresented) //safeguard against click happy users
this.NavigationController.PresentModalViewController (StaticViewController.staticViewController, true);
}
You should add the static views to your UINavigationController or whatever controller you are using for managing multiple controllers.