After creating a new storyboard i can no longer connect buttons to my .h header file by control dragging from the button to the IBAction- using Xcode 4.3- I get no errors -and I can still connect buttons to my previous storyboard for the iphone, but not for the storyboard for the iPad.
Kindly click your Identity inspector and check the Class type of the Storyboard
I'm new IOS and XCode. I added some bottuns to my IPhone app and now I want to add to them functionality.
I found this tutorial.
The problem is that when I drag the button to ViewControler.h it bounces back.
Please advice.
Thanks,
Nahum
press Ctrl button + drag the your button to viewController.h then "Insert Outlet and Outlet Collection" will be appeared. After that you remove your finger on mouse you will get Outlet box regarding connection. It has connection, Name, Type properties. I think it will be helpful to you.
You can make UIButtons or any UIControl one of two ways
By Programmatically
By .xib file
I think you are talking about the second method.
In the second method you take UIButtons in class:
#interface className : UIViewController{
IBOutlet UIButton *buttonName;
}
Now you will have to click on the .xib file and then you have to select a file below responder; after that open connection connection inspector. Now you can drag and drop UIButtons on the .xib file and establish a link between displayed UIButton in connection inspector and .xib's UIBUtton.
I have a custom UIView (created without InterfaceBuilder) in my app. And I want to insert an UIButton into it, but I don't want to create the button prorammatically.
So I want to create UIButton in Interface Builder and then put it into my view.
My first steps were:
1) Create XIB from "Empty" template
2) Drag RoundRect button from Objects Library onto this XIB
3) Save XIB as "MyButton.xib"
were these steps correct? and what's next?
IMHO connect the View and the UIButton from your XIB-File to your custom UIView-Class.
After that creates the click-method for this button and have fun :)
I am trying to do something as simple as add a Label to a View in XCode and IB and I can't figure out how to do it. All the samples I find online are for older versions of IB so the directions aren't correct.
I have a label on my .xib file, in my Controller.h file I have an IBOutlet UILabel declared with a Property set up.
In my Controller.m file I synthesized that Property.
In Interface Builder, I cannot for the LIFE of me figure out how to associate my label in my code with the Label on the .xib.
Whenever I try to drag the Connection to File's Owner, the only option that shows up is "View".
If I look at the Controller under the Library Window of Interface Builder, the Label shows up as a UILabel under Outlets. I am pretty sure that it used to be a type "id", but it automatically shows up as UILabel and if I try to add an "id" one, it doesn't work either.
Can someone point me to somewhere to explain this stupid thing? It should not be this difficult to make a label have text.
Assuming your view is called ExampleView. Click on the file owner and then press ⌘+4. This will highlight the identity box. Make sure that the class name is the same as the name of your class.
Save and close Interface Builder and then go into Xcode and verify:
// ExampleViewController.h
#import <UIKit/UIKit.h>
#class ExampleViewController;
#interface ExampleViewController : UIViewController {
IBOutlet UILabel *label;
}
#property (retain, nonatomic) IBOutlet UILabel *label;
#end
In your .m file:
// ExampleViewController.m
#import "ExampleViewController.h"
#implementation ExampleViewController
#synthesize label;
Then save the xcode files and open up your ExampleView. Drag a label onto the view. You are not supposed to connect that label to the Files owner.
INSTEAD YOU CLICK THE FILEOWNER. HIT ⌘+2 this will open the connections box. then you will see your outlet. Click and connect that to your label.
Make sure your property line looks like this:
#property (nonatomic, retain) IBOutlet UILabel *label;
Leave (or set) the type of the label as UILabel in Interface Builder. If that doesn't work, try File -> Reload All Class Files in Interface Builder. Your code looks good, but CardNameLabel should start with a lower-case 'c'.
Try this: click on the File's Owner icon to select it, and go to the Inspector's Identity tab (the 4th tab) and check the value of the Class setting. My guess is that's it's currently set to UIViewController.
Since the class that has the IBOutlet you declared is (or should be) a subclass of UIViewController, you'll need to change the class name to the name of your subclass (e.g., MyController, or whatever it's currently named).
Here is how to connect a UILabel to your storyboard in swift:
Click the icon in Xcode. If you are using an older version of Xcode, use the Venn Diagram at the top right of the window.
Using the bar at the top, choose your storyboard on one half of the file viewer, and your view controller on the other side.
Press control, click the UI Element you wish to create an IB Outlet/Action for, and drag it to the View Controller file:
Choose your preferences for your IBOutlet/Action:
You have successfully linked your storyboard element to your code.
You can follow this tutorial to see a video on how to connect your storyboard element to your code.
Assume that you have a viewController and a xib file which has a UILabel on this. The steps to connection the UiLabel (also the xib file) your viewController are:
1) In the header file, create UiLabel object and property for it
IBOutlet UILabel *label;
#Property (Nonatomic, retain) IBOutlet UILabel *label;
and synchthesize it in implement file
2) Open your xib file in Interface Builder
Double click on "File's Owner" then select the viewController in dropdownlist of pop-up windows to connect your xib file to controller
3) right-click on file's owner, on the pop-up dialog:
point and drag the plush (+) next to "View" and drop it on View row
point and drag the plush (+) next to "label" and drop it on the label on the view
=> now the label and the view on xib file is connected to you controller
OK, here is how to re-create the problem had:
Create a new project, using the
Tab Bar Application
Add a UILabel within SecondView.xib
Add IBOutlet UILabel* myLabel; to FirstViewController.h
Connect up myLabel in IB.
Build and run.
When I click the second tab the app crashes with:
__TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION__
In IB, when using UITabBarController which has multiple UIViewControllers which all separately have their own NIB file assigned, there are two places where you need to set your UIViewController class file.
First, the obvious one was within the NIB file for each UIViewController.
Secondly, where I'd missed it, is withing the NIB file for your UITabBarController. In each UIViewController, not only do you set your NIB file, but also the Class.