I have two storyboard files, and one view controller that I would like them to share. On one storyboard everything works perfectly, but on the other it is not linking. When it loads it's just the buttons and stuff that do nothing when I click on them, and in the interface builder I can't link them because they're not showing up. So I've come to the conclusion that my files aren't linking correctly. How can I fix this?
Related
I have an app that has many different views. The entry point to the app is the home page where I have 2 buttons (note that the home page is embedded in a navigation controller). Each button leads to a new stack of views, I tried embedding the first view of those stacks into a navigation controller, but when I push a button on the home page that leads to a new stack, the app crashes giving me a "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'" message. So I avoided embedding the stacks into a nav controller. The problem happens when I push the save button in the last view of the stack. In there I did the usual
self.navigationController?.popToViewController(firstViewController, animated: true)
This does not work and I get sent to the firstViewController, however the navigation bar buttons don't show up, the background is black and nothing shows. If I popToRootViewController however, it works. Cheers!
Alright well I feel stupid now, I realized that the segues between my buttons and view controllers were push segues. Now I embedded the first view controller of both stacks in a navigation controller, and changed my segues into modal segues. By doing that I was able to use popToRootViewController instead of popToView Controller... Now my save button leads back to the view controller I wanted to show, everything works fine.
After I set up my new project with libGDX v1.3.1 i am stuck with something that should be easy. In my main class which extends game I have:
Gdx.input.setCatchBackKey(true);
but I cannot get any response from this (in render method):
if(Gdx.input.isButtonPressed(Keys.BACK)){
this.dispose();
}
It like nothing was pressed, although I can see that the button was pressed in logCat console.
I need to mention that I was using the exact same code until libGDX version 1.0.0 (or the first one with gradle).
Note: i have also tried implementing InputProcessor and then setting the input processor. Result was the same.
And for the home button: using Gdx.input.setCatchMenuKey(true); is not working.
Use isKeyPressed instead of isButtonPressed. Buttons only refers to the three mouse buttons on a desktop game. Everything on Android is a Key (or Peripheral).
You mentioned "home button" but the code you posted is for the menu button. There is no way to catch the home button unless you make your manifest declare your app as a launcher replacement, in which case, the home button will always open your app, even when it's closed, and the user will have no easy way to get to the home screen. And libgdx doesn't have that functionality built in, since that would be weird. You would have to implement it yourself in your manifest and main Activity.
Also, disposing of this, whatever this is, sounds dangerous to do from the input handler. You could be about to render stuff and cause a crash. But I'm not sure where you're trying to use it from. Maybe it's OK.
I want to set up my view controllers like the Find My Friends iPad app. Based on what I've found so far, I believe that I need to:
Use a container view controller
Make the tab bar controller the root view controller of the container view controller
Add other view controllers, such as split view controller, as child view controllers to tab bar controller
Add some sort of callback methods to forward messages from the parent to the child view controllers (for rotation and appearance)
Can someone please confirm that I am on the right track? Also, if you can point to or add some sample code to help me get started, I will appreciate it.
Thank you.
You are correct. All 4 tabs on the "Find my Friends" iPad app are split views. It is actually very simple to get started with an app like that. I'm not sure what direction you are planning to take as far as content, but at least for the layout. Start a new project in Xcode and then choose master-detail application. It will automatically setup a split view with the left side as a table view and the rightside as a detail view. it will also presetup some editing methods and what nots. If you will be using core data at all, i would also highly suggest starting that with the checkmark as well. Good luck with your app!
This document outline from my sample Storyboard shows what I'm working with.
I have a custom container view controller and two content view controllers connected via embed segues.
Here is the storyboard itself.
ZetaViewController has to create some programmatic views (within ZetaView, of course). I noticed when I was centering these programmatically created views they seemed really off center.
ZetViewController is centering things by examining self.view.bounds.size.height and self.view.bounds.size.width and doing some appropriate arithmetic.
When I added debug logging to ZetaViewController, I noticed that self.view.bounds.size.height and self.view.bounds.size.width had dimensions equal to ContainerView (768 x 1004) and not ZetaView (728 x 637). The Size Inspector in IB confirms these values.
I created a distinctive value for the tag attribute of ZetaView and logged it. ZetaViewController.view really is ZetaView because the tag value confirms it.
So what is going on? Why would ZetaView, shown clearly with smaller dimensions on the Storyboard and in the Size Inspector, show the wrong values in it's properties during run time?
My problem had nothing to do with Storyboards, segues, or custom container view controllers vs content view controllers. It had to do with the new Cocoa Auto Layout features introduced in iOS 5.
My problem arose from inspecting view bounds size in viewDidLoad instead of in viewWillLayoutSubviews. At the time viewDidLoad is called, the view controller's view has not been given its proper size yet. When I moved the code which programmatically centers views to viewWillLayoutSubviews, it worked as I expected. I still leave view creation code in viewDidLoad because viewWillLayoutSubviews is called repeatedly as layout changes.
See also the View Programming Guide for iOS section "Tweaking the Layout of Your Views Manually".
Ok,I'm going to point to an excellent post that I found: (updated)
http://kevindew.me/post/18579273258/where-to-progmatically-lay-out-views-in-ios-5-and
I was having an awful time adding shadow calayers to views after autolayout had done its magic. viewDidLoad, viewWillLoad etc did not have everything correctly laid out.
viewWillLayoutSubviews is called quite a few times and the state isn't fully set up. However... In viewDidLayoutSubviews, finally everything was set up as I expected.
I am new to Monotouch and I am not finding the right documentation to do this.
I created a new iPad Storyboard Single View application. I have my inital Navigation Controller, my initial View Controller, and then I added two more View Controllers (Pages?). I created a button on the first two pages. I held down control and dragged each button to the next View Controller and setup each Segue as a push. When I run my application, I can move from page 1 to page 3 and back, no problems.
Now the problem is when I start adding controls and trying to wire them up. On the initial View Controller, I can hold down Control and drag controls over to the code and after I give it a name, it automatically adds my outlets and actions.
But the new two View Controllers I cannot do this. I have searched every where and the StoryBoard documentation and examples are difficult to find. Any help would be appreciated. Thanks!
You need to create a UIViewController class for each of the new View Controllers in Xcode, if you right click on the folder for where you want to create the class, then click Add New.
You then need to then wire them up to your View Controllers in the storyboard (you will see a drop down which shows the name of the class for the view controller in the properties I think it's the fourth icon from the right, it will be UIViewController). Once you have done this, you will then be able to wire up the controls on it.
Once you've saved it, it will automatically create the C# classes in MonoDevelop when you switch back to MonoDevelop. Don't try and do the class in Mono first as it causes you all sorts of issues!
Hope that helps, if you want more information about storyboards, I've found that the objective c stuff is about as good as you can get for now as there isn't too much support for monotouch storyboarcs yet.
Davoc