Swipe gesture without messing the navigation bar? - xcode

This is hard to explain but i'll try my best. I have a Table View controller that leads to 10 View controller. All the View controllers have a navigation bar title (The titles are the 10 objects from the Table view controller). Now i want to add the Swipe Gesture for a easier navigation between the 10 table view items (Instead of going back to the Table view manually i want the user to be able to swipe to change from a view controller to another). HERE'S THE PROBLEM: When i add the Swipe Gesture and i connect it from one view to another, it asks if i want the action to be either: Push, Modal or custom. Now, if i choose one of them, it makes the navigation bar title disappear. I want to keep the title without messing up the connection from the table view to the views controller. Thanks.

You want a pageviewcontroller. Set up the pages to be your different view controllers
A pageviewcontroller essentially allows you to do exactly what you want to do without having to setup a new segue every single time. That way it can all happen under one navigation bar. If you've seen the twitter app, you know how you can scroll through your feeds? Same thing.
There are tons of tutorials on the web, but pageviewcontroller a can be a tiny bit tricky because they require some logic
Here's a slightly more advanced thing that might be useful to you:
https://github.com/cwRichardKim/RKSwipeBetweenViewControllers

Related

How to transition e.g. fade, from one view controller to another

I have done a lot of research on Youtube, websites and Stack Overflow, but couldn't find anything that worked. Hopefully, you can help me. I have view controllers in Xcode, and buttons on them that perform segues, to show the next view controller. But when it changes view controllers with the button performing a segue (show), it brings the next view controller up from the bottom of the screen. How do I change the transition (or add a transition) to make them fade into each other.
What you’re doing(the segue) is presenting the view modally. This is an Apple defined behavior which we get for free.
What you want is a custom view controller transition. Therefore you’ll need to implement it yourself.
Luckily, Apple has a great system built-in that makes creating custom UIViewController transitions easy. Although it will require some familiarity with iOS libraries and experience with animation logic.
You can check out this article.

How to make storyboard go to correct item in document outline when clicking on a view controller in graphical view

I have a lot of view controllers in my Storyboard which makes navigation a bit difficult. When I click on a view controller or other item in the document outline, it will scroll automatically to the graphical representation of this view controller. However, when clicking on the graphical representation the document outline list does not automatically scroll to the selected item. I have to scroll through this list until I see something selected to know it is the correct one.
Is there a way to select a view controller in the graphical view, and let the document outline scroll to this view controller?
Another related annoyance is that if you filter the document outline to find the correct view controller, and click on that view controller, it will be scrolled away when you reset the filter again. Is there any way to prevent that from happening?
Is there a way to select a view controller in the graphical view, and let the document outline scroll to this view controller?
When clicking on an object (view controller, view, etc.) in a storyboard scene in the graphical editor in Xcode, Xcode 6 does scroll the hierarchical view so that the selected object is at least partially visible. Also, hierarchical list for that scene opens up so that you can see the object. So in the 2 years since you asked this question, at least that much has improved.
Another improvement: if you point to a view controller at the top of a storyboard scene in the graphical editor, a small view pops up with the name of the scene, which makes finding it in the list a little bit easier.
if you filter the document outline to find the correct view controller, and click on that view controller, it will be scrolled away when you reset the filter
This also seems to have improved: the selected view controller remains visible even after clearing the search field.

xcode segue jump management in a app with many views

I have seven views that I need to navigate between from any of the other views. I don't want to keep doing segues from each one as new instances would keep being created...among other issues. What I was originally trying to do was have all the segues start from a home view and then go to the designated target view. When the user left that target view a public variable would be set if they wanted to go to any other view other than the home view. When the home view reappeared, it would check that public variable to see if another jump was needed. In the Home view I put the segue jump check in the -(void)viewDidAppear:(BOOL)animated function. The problem with this being you see the home screen for a second before it goes off to the new target view. The -(void)viewWillAppear:(BOOL)animated does not work for segues. I guess this is because it hasn't fully released the old segue yet?
Is there a better way to handle a freeform many view navigation issue like this? If anyone needs it, I can post some sample code for what I was trying to do. Thanks in advance for any help.
It sounds like you need a UITabBarController.
It allows you to have multiple view controllers, and switch between them by tapping the tab on the bottom of the screen.
It allows you to have only one instance of each controller, so that as you switch between them, data persists and you aren't creating new instances each time.
Here is an example of what one looks like (notice the tabs at the bottom of the screen):
(source: xamarin.com)

Advice needed for developing multiple window Mac application

I’ve been reading through several books on Mac development, but cannot find the information I’m looking for.
The books all describe how to make floating windows or panes, but never mention how to make them all in one window. A simplified example of what I’m looking to create is shown below:
Basically, there will be three windows; A selector window with radio buttons to choose which NSDocument is currently being used, a window underneath that with buttons that show different windows to the right that allow viewing and manipulation of certain data.
For a example, each NSDocument may have a color value that can be set in the window shown by clicking view A, and some text strings that can be set in the window shown by clicking view B.
So the questions are:
Is it appropriate to use a single NSDocument sub-class for each Doc #1 and Doc #2?
Which classes should I use to set up the application as shown? NSWindowController? NSWindow? NSPanel?
I’m only looking for guidance on what to read up on, so any pointers are appreciated.
EDIT:
To clarify this further, I want to have a table view where the buttons are (View A & B), and by clicking them they will cause the other window/view to change it's contents.
It's like the split view in the iPad settings application, there is a table view on the left, and when it's pressed the right side changes.
The radio buttons are there only to illustrate that I want more than one Document. I'm guessing I need more than one to handle this? Or perhaps I should place them all in a single NSDocument? Somehow that doesn't seem right.
To achieve what you want you need one window (NSWindow), one window controller and various views each with their own view controller. There are several ways you could set this up, all depending on your requirements:
You'd have at least 3 views (instances of NSView): one for the selection of the document class, one for the view selection and one for the content. Each view is controlled by a view controller (instance of NSViewController). Additionally you can opt to wrap the views in split views (NSSplitView) so your user can resize the real estate available to each view.
You have one window with a window controller. If you choose a Document based app template in Xcode, Xcode will generate a subclass of NSDocument which you can use as your window controller (or choose to use Core Data and Xcode will generate a subclass of NSPersistentDocument with all bells and whistles you need to access Core Data for document persistency).
So to come back to your questions:
1: Yes, but depending on your requirements. If Doc #1 is a completely different thing than Doc #2 than you might need to re-evaluate. For example Doc #1 might have completely different persistent requirements than #2.
2: There's no single scenario here, but one that worked for me: Take the project template for a document based app (with or without Core Data). Use the generated subclass of NSDocument (or NSPersistentDocument) as your window controller. Use NSView to implement the views in your window where each view is managed by its own controller, which is an instance of NSViewController.
I know this is an old question, but a way to do it how you want would be to use: ContainerViews and set their embed segue to be the view controllers you want.

XCode tabBarController with custom button navigation

I had a question previously that died out and wanted to post a different approach and see if it was possible.
I have a working application that has a UITabBarController that controls 4 distinct UIViewControllers. I am able to navigate fine through these, but a couple of the loaded views need to load others in order to perform actions.
Is it possible to have a button within a UIViewController that will replace the current view with a different one and still maintain the tab bar on the bottom? possible replacing the current view and advising either the new UIViewController or the owner tabBarController that the relationship is still the same?
I can post code and further clarify if you wish. I am VERY new to XCode so i'm not completely familiar with how everything operates as of yet.
thank you in advance,
Silver Tiger
Yes you can add new view to one existed in the tab.
For example, if your view controller in tab is of type navigation based then you can push the other view upon certain event.

Resources