xcode can't link UIButton to action - xcode

Learning Xcode and making a simple app. A "contact" button takes to a subview. Here buttons for Phone, email, UrL for a website.
Storyboard and assistant editor are side by side.
If button is on the first main controller no problem.
But on the subview it wont let me connect a button to a method.
Not sure if there is a simple answer to this.
thanks

Related

How to connect a button and collectionview in tvos application?

I am trying to connect a Button and Collectionview in my tvos application (Xamarin - Visual Studio Mac). I need to show the collectionview when tap the button.
I am following this blog for the implementation of collectionview in my project. The 6th step on this blog tells how to connect the Button and collectionview , Control-drag from the Button to the Collection View Controller and select Push from the popup:
Screenshot
I tried a lot by dragging the Button to Collectionview, but there is no popup and they are not getting connected. I am a beginner on tv os application development. So anybody please explain this mechanism? If provide a gif file, it will be easy. :)
Focus on the button and click the Control on the keyboard at same time .
Move the mouse from the button to the CollectionViewControl .
Now the popup will display.

Linking actions to buttons on a modal/popover segue (swift 2 Xcode 7)

I'm sure I'm asking a simple question but I've only just started coding... so take pity on me!
I'm trying to figure out how to connect buttons (actions) to the viewController.swift from a modal/popover segue (I think the solution is the class but whenever I change it I get an error).
Eg.
In the storyboard, on the viewController interface, I have a button for sharing files. When I click it, a popover segue appears with two buttons on it, one for Fb one for Twitter, but I can't connect any actions from them to the viewController.swift
In another project I made a Google+ login and connected it to a modal segue but I couldn't make that work either.
Is segue the wrong thing to use?
Thanks for your help!
Marie
Your question would be easier to answer if you'd provide the actual error you're getting when you try to change the class.
It sounds like you're trying to connect the popover's buttons to actions in the presenting view controller (that is, the view controller that presented the popover), rather than the view controller of the popover itself. If that's the case, then that's the problem. You can only connect your buttons directly to actions available in the current scene.
This means you need a custom class for the presenting view controller (the one with the button that segues to the popover controller) and one for your popover. Set each scene view controller's classes to the appropriate custom classes you created (which must be a subclass of NSViewController or one of its subclasses or you won't be able to set the class name in IB) and you should be able to drag connections.

Why doesn't "Navigation Item" show up in one of my ViewControllers in Interface Builder?

I have some working navigation between ViewControllers, using a UINavigationController.
But if you look in the image, you'll see my ViewControllers in InterfaceBuilder have an item called "Navigation Item" which showed up when connecting it to the UINavigationController.
However, the TutorialViewController doesn't have this. How do I get it to show up? I tried copying the Navigation Item from one controller and pasting it into another, but that didn't work.
The really weird thing is that if I use the button on the front page to go to the Tutorial page, the navigation works, shows a back button and everything.
Just drag & drop a Navigation Item from the object library onto your ViewController in InterfaceBuilder

iPhone simulator not responding when using storyboards

I'm quite new to iOS Programming. I've done Objective-C for about a year, and now I want to start making apps for the iPhone. I think I'm missing out on something really simple, though. What I've done is this:
First I created a new Single View Application with TestApp as a product name. I enabled Use Storyboards, Use Automatic Reference Counting and Include Unit Tests. After creating the project, I dragged a UIButton onto the View in the storyboard file.
Note that I didn't write a single line of code. I launched my app in the iPhone Simulator and pressed the button, but it's not responding. I know I didn't assign an action to the press of the button, but the gradient of the button isn't changing, as I know it should. The User Interaction Enabled properties of both my view and my button were enabled.
Recently, I've created a few apps in Xcode that worked just fine, but I didn't use storyboards in those projects. Thus, I'm guessing there's something extra to do when using storyboards of which I'm just unaware. I'm using Xcode 4.5 and the iPhone 6.0 Simulator.
I wrote NSLog(#"View was loaded."); statement in the viewDidLoad method of my ViewController to make sure this view controller was actually loaded. (I know my button wouldn't show up if it was the wrong view controller, but I did this just to make sure.)
I also wrote a changeTitle: method in my ViewController to change the title of my button to New Title after it was pressed, just in case the button worked but its gradient just wouldn't respond to a tap. I linked this IBAction to my button, but it wasn't called.
In my ViewController, I created an IBOutlet of a UIButton which I connected to my button. In the viewDidLoad method of my ViewController, I changed the title of my button to New Title, this actually worked. The title of my button changed to this new title when launching my app in the iOS Simulator. The button itself still wasn't responding, though.
As a last try, I also wrote [button setEnabled:YES]; in my ViewController's viewDidLoad method, but this didn't help. My button still doesn't respond to any tap. What am I missing out on?
This is weird. I had an issue with my printer, so I restarted my computer. After this, this issue was suddenly solved as well (just like my printer issue). I'm not sure how this could have affected anything, but I'm glad it works again!
Ran into the same issue.
Apparently Content Reseting the Simulator worked for me
Very strange this..

Switching views in storyboard after executing code in xcode

I made a log-in screen that once you press the button to log-in and it authenticates the user name and password. What I want to do it switch to a different view after the authentication is completed. I am using a storyboard for this application and I have set it up so that the log-in button does a modal seque but it doesn't switch the view. I tested this with a sample button and all it does it switch the view back to the same view and refreshes the view. What do I need to add in order for my function to switch from my ViewController View (the main view) to the next view (RootViewController).
I have a navigationController and an object created from the ViewController class but I don't know how to use them in order to switch views.
Can anyone point me in the right direction? I can provide more information or sample code if needed.
If I'm following your question correctly, what you're looking for is performSegueWithIdentifier:sender:.
In general the apple documentation on view controllers in storyboards is pretty good and covers all of the relavent bits for transitioning between views in storyboards.

Resources