Objective C - Create modal Segue - objective-c

I'm having some trouble figuring out how to use the Storyboard correctly. My main issue being Modal segues. I have a viewcontroller which I'm trying to display modally (far right in image below). But it just isn't showing. The prepareForSegue is firing correctly.
It does work when I change the segue from a Modal to a Push though.
I'm calling the segue using
performSegueWithIdentifier:#"FirstRunSegue" sender:self
Here is the visual segue setup I have at the moment
When I hover over the Excaimation mark, the following error is displayed:
I am kind of new to Storyboarding, so I'm hoping that someone could explain why the modal segue isn't working and how I would get it to work. The nasty thing is that it is a requirement for the viewcontroller to be in the Storyboard, otherwise I'd just initialize the controller and display it manually.
Regards,
EZfrag
Edit 1:
OK, I managed to figure out why the segue is not being displayed. It is kind of stupid, because it works for a push. It seems that I cannot call a modal segue from the appdeletegate's startup function. Push works fine, but not modal. Confirmed it with a new project.
Is there someone that can explain why this is so?
Regards,
EZFrag

You can only use the push segue with a UINavigationController, but it looks like you are trying to use it between two regular UIViewContoller. If you want to change the way the animation looks, use a custom segue and write your own transition.

Related

View Controller trouble in Xcode

I just now figured out how to add a new view when you press a button. For example, in my storyboard, I am using a tabbed controller and in my first viewController i have a button in the top right corner on a navigation bar. and when i press that button, it directs to another view controller. I was wondering how I would be able to write the code for that view controller? I tried creating a new file > objective-c class, but I dont know how to link them together? any help?
If you've made that other controller in the storyboard, you just change the class of that controller to your new class that you made. You do this in the identity inspector.
Use navigation controller to navigate between your view's, You have to make an IBACTION method fot the button. In which you will navigate the view you want by pushviewcontroller.
Please see this link...
How to push viewcontroller ( view controller )?
It implies that which class has to be initialized and what is the nib name of this class. We should not do anything in this block, until you need that your code to be executed before viewDidLoad/viewWillAppear.
Turns out that there is no code necessary to get a button to direct you to another view controller that you set up. You have to declare the button obviously in the #interface part, connect the button with it's code, and then you have to use an action connection from the button to the next view controller you want the button to activate. I have used a modal connection personally, mainly because I'm not sure what a push connection is or what it does... But Ya I figured it out! Hope this helps to any other people who need this!

Dismiss custom modal view controller

I'm developing an iPad app where I've created a custom segue to present my view controller with a custom animation. It's now working (almost) fine and in the end it looks like a form modal view controller, exactly how I wanted it to look.
Now I need to create a custom animation for dismissing the modal view controller that matches the first animation.
What is the best way to do it? I have my custom animation inside my custom segue and I think the reverse animation should be there also. But I also think the segue is not the place to have it.
How'd you guys do it?
Thanks
Unfortunately you can't use the segue to perform the dismiss of your modal ViewController its jut one way (will change in ios6). just perform your custom dismiss-animation and call dismissModalViewControllerAnimated:NO on the parentViewController in the finished block of the animation.

Increasing number of living Views

I've set up a really simple project using storyboards including two views as shown here: http://i.stack.imgur.com/iRx21.png. The navigation can be done by either selecting a cell in the custom table view or hitting the back button labelled with "<<". Everything works fine except the following:
when I switch between the views, every time an instantiation happens. The profiling shows an increasing number of view objects. I would like to keep only one of each view and instantiation should be happen only once. What am I doing wrong? (I'm using ARC.)
Thanks in advance!
You should not link your back button to the parent view controller. This is what causes the new instantiation.
The way to go is to embed the table view into UINavigationController (in IB, choose Editor -> Imbed In -> Navigation Controller. Then change your segue to a Push segue. You can of course hide the navigation bar etc. to make things look exactly as you like. Then, link the back button to the controller with an IBAction and in the handler do a simple
[self.navigationController popViewControllerAnimated:YES];
This would be the appropriate logic of what you are doing. Of course, you can also push the web view modally and then handle the button click with
[self dismissModalViewControllerAnimated:YES];

MonoTouch: StoryBoarding - manual segues?

iPhone/iPad dev newb here...
I am using MonoTouch to create a universal iPad/iPhone storyboard app. In the primary view controller (RootViewController) the default auto-generated behavior is a table with a single cell "Detail" in it, which hardwires you to the next destination (DetailViewController).
I'd like to change this RootViewController to instead show a login control I've made extending UIViewController (LoginView). I have had some success putting the LoginView inside the RootViewController, but can't figure out how to make it 'segue' to DetailViewController. And upon watching how the iPad app works, where there is no segue (that I can see) between the two, am I going about this wrong?
To summarize: How do I enhance this storyboard app with a preceding login screen, reusing its contents/xib between the iPad and iPhone variant?
Apologies if this is a bit unclear and muddled.......
I have not tried a storyboard app in Monotouch yet, but I did spend a lot of time working out the best approach for a login screen for my application. What I ended up doing, which could work in your situation as well, is presenting the login screen as a Modal view. Once the user has successfully logged in, we then push the next appropriate view.
So if you are automatically pushed into the detail view by the storyboard viewcontroller, you could display the login dialog as a modal dialog from the detail view's DidLoad or DidAppear methods.

popViewController problem in tableViewController

In my app delegate I have a navigationController property.
In my first view I have some buttons and tapping them will make another view appear when it is pushed on navController.
In this new view there is another button to open a UITableViewController by pushing it on the navController.
The problem is in the last view, UITableViewController, in fact in viewDidLoad, if I have no data, I try to pop it off the navigationController but my app crashes.
However, if I connect the pop to a button it works great.
I reference my app delegate instance in order to popViewControllerAnimated:, so what is the problem?
I'm not sure what's wrong with the code, can you post your viewDidLoad method?
Also, is it possible to check whether your table will have data BEFORE you push the tableView onto the nav stack? That would be a much cleaner UI, rather than showing and then immediately popping a view. If there is no data, disable the button that launches the table view.