I'm working on my 1st real game. I have 2 view controllers. The 1st one has an animated picture, and the player can enter there names. The 2nd one is displaying the game. After the game is over the player can play again or reset. The reset takes them back to the 1st VC so they can give new names. My question is how do I hide the reset until I need it. To put it there I made a button and command dragged it to the 1st VC and selected show.
Thanks for any information you might be able to give me.
If you are using iOS predefined back button then try like this:-
navigationItem.hidesBackButton = true
or if you have just dragged and drop the UIBarbutton then create the outlet and hide/show it accordingly.
If you have an outlet variable to your reset button, you can change the isHidden property of it to true or false appropriately.
Related
I am creating an app that requires notifications. I created a settings page with a switch to toggle notifications for the application. I tried to link the switch to ViewController2 using an #IBAction, but it keeps connecting the object to Exit, instead of ViewController. I am getting really frustrated because the #IBAction won't stay connected. I am not sure what is going on, but if I could get help that would be amazing.
The images are linked down below to Imigur.
This is the connection to ViewController2
This is what occurs when I connect the IBAction to ViewController2
You can see there is no action option for the connection in this image.
When you attach #IBActions (or #IBOutlets), you do not want to attach them to Exit on the View Controller.
Follow these steps to add an #IBAction:
1) Make sure your View Controller's class is linked to your file, then go into the Assistant Editor making sure you selected Automatic.
2) Hold Control (^) and drag the button to your ViewController class.
3) Add the button as an #IBAction. - It's also recommended to use UIButton as the sender, instead of Any.
It should look like this:
If you have questions, let me know!
The problem might be that you are supposing you can form an action connection from a UISwitch in the scene of one view controller to a different view controller. You can't. You can form outlets and actions only between a view controller and the interface inside the same scene of the storyboard.
Click on the top bar of your problematic ViewController (the overview of what is getting displayed on screen), click the top left icon (called View Controller).
On the right click "Show The Identity Inspector" icon and you should see class. Change the text to 'ViewController'. Hopefully it should auto fill.
This will solve the problem.
i am trying to set up a pageviewcontroller that has embedded buttons ( those that dont move when the page view is swipped left or right but are constantly visable )
i have the standard viewcontroller, the pageviewcontroller, and another viewcontroller that has an imageview. the problem is that regardless where i place the buttons they move off screen whith the swipe an reappear with the new image.
is there a way of embeding them so they dont move off each swipe?
ive even tried placing an embedded navigation controller on the first viewcontroller but with no success.
thanks for the advice.
if you don't want them to move, you have to put them in the view controller that contains your UIPageViewController. So they will be only one instance of the button (not one for each pages).
I have a button in my app, but I have create a UIButton subclass that adds another view and a few labels on top of it. The problem is that now in my app the button does not respond to taps. How would I go about fixing this?
I was able to fix this problem by setting the view that was covering my button with the property
userInteractionEnabled = true
That allowed for the text to go through my view back to my button
I'm working on trying to figure out storyboards and it all seems pretty cool but I'm having problems with moving from one screen with a few buttons to another screen no matter which button is pressed. Obviously I can control drag from each button but then I have segues all over the place on the story board and I feel like there has to be a better way to do it. I've tried highlighting all the buttons and control-dragging to the next screen but that only caused the one I dragged from to work.
Here's an illustration of what I have that works right now...
If I have to stick with this then so be it but I'm going to end up with 6 buttons on one page and 8 on another. That's alot of segues. Basically each button signifies a choice for the user. That choice will cause different things to happen behind the scenes but no matter which button they choose they move to the next screen.
What I've Tried:
Highlighting all the buttons and then dragging to the next view controller.
This failed because it only connected the segue to the button I clicked on when I control-dragged
Dragging out one segue then dragging from the second button to the circle part of the segue.
This caused nothing at all to happen.
I'm unaware of a way to give a single segue multiple triggers in a storyboard, however you could create a single segue with a particular identifier, and then have all of the buttons respond to a single IBAction that calls [self performSegueWithIdentifier:...];
Check out generic segues, which are tied to the source view controller instead of an IBAction:
https://stackoverflow.com/a/8868096/295130
I have added add(+ symbol button) button to my navigation controller.
When I click it a view appears from bottom. I added a navigation bar and two buttons to it.
One save and one cancel button. And the view have one textEdit box. After editing I can save or cancel. If I touch cancel I need the view to disappear like it should go down again.
I think all iPhone , iPodTouch users use it. Like when they touch Add item then a view appears from bottom and when they cancel it goes down again. How can I make in this way in my application.
Maybe you're talking about a UIActionSheet?!?
http://developer.apple.com/IPhone/library/documentation/UIKit/Reference/UIActionSheet_Class/Reference/Reference.html