Why is my IBOutLet connected to another project's storyboard? - ios

I have two projects. And there are two class which has the same name in each project. And these two classes have an iboutlet which has the same name. If i open only one project, it's normal. But if i open both, one of my iboutlet is connected to view in other project's storyboard.
Is this a bug of xcode?

Related

IBOutlet to two viewControllers on two storyboards... is that possible

I have an app with two targets, for iPhone and for iPad.
This project is not using size classes.
On the iPhone version I have a storyboard that contains a viewController called “termsAndConditions”. This viewController has class files termsAndConditions.h and .m.
Inside termsAndConditions.m I have an outlet linked to a textView on the viewController.
Then I have the second target for iPad. I have the same viewController there called “termsAndConditions”. My idea was to use the same class files termsAndConditions.h and .m from the iPhone version with this other target. But there is a problem.
Remember that the outlet is pointing to the textView on the viewController of the iPhone storyboard? When I assign the iPad termsAndConditions viewController to use the same iphone class files, it apparently works, but when I try to access the textView on the iPad version nothing happens. On the other hand, when I pass the mouse over the outlet on the implementation, textViews on both viewControllers, on both storyboards, highlight.
Apparently the class file outlet is really linked to both textViews on different storyboards, but this appears to be fake.
Is there a way to do that or will I have to duplicate the termsAndConditions.h and .m with another name to use on the iPad storyboard? This appears to be a stupid solution.
thanks.
You may connect 1 object to your class per view controller. Double check that you set the classes correctly; I often accidentally autocomplete the incorrect class. Ex. TermsAndConditionsTableViewController instead of TermsAndConditionsViewController
This IBOutlet is connected to three different views and works correctly for me. Click on the dot to show the connections. Sometimes you need to make the connections again (rare but does happen).

UITabBarController is not working?

I just drag and dropped a UITabBarController into XCode 6 xib.
It comes with two viewControllers by default.
But when I am trying to run app I am getting this
The thing is I am couldn't able to see bar button items and neither viewcontrollers.
How to deal with that?
So I assume you are using a storyboard, not an xib? If not, then you need to use a storyboard, then go into your info.plist file and add the following key-value:
"Main storyboard file base name" : your_storyboard_file_name_without_the_extension
Then make sure in your project settings > deployment info > main interface, you also point to that storyboard.
your xib file has to be set as the "Main nib file base name" in your target's info.plist file, like on the screenshot (in my case the xib file is called Main.xib):
in your application's delegate header file, the window property has to be declared as IBOutlet (so it can be set through interface builder):
#property (strong, nonatomic) IBOutlet UIWindow *window;
in the xib file, create an object that will represent your application's delegate object - be sure to set it's Class to your delegate's class name (in my case the class's name is "AppDelegate"):
create a window object in your xib - this will be the main window or you app.
connect application's delegate window outlet with window object:
connect the window's roootViewController outlet to your tab bar controller:
so this is how you do it with a xib. although, I'm not saying it's simpler than using storyboards..

How to connect UITableView to new created UITableView class?

This is a very simple question. I was following a very basic youtube video but a little bit in different way. I have a UIViewController. There is a button on that called "History". When I press history I need to open a table view and show the history. Step I did is:
Drag and Drop a UITableViewController
Create a new file which is UITableViewController
So I have UITableViewController.h and UITableViewController.m file
Now I want to connect this UITableView to this new class and implement it. In the video said I must press Ctrl and drop in on the .h file to create an IBoulet
After pressing connect this must appear
#property (strong, nonatomic) IBOutlet UITableView *tableView;
But in my xcode when I drag and take it to the .h file there is no plus sign to connect them together.
select your table view in interface builder. And at the right side of screen you will see object inspector menu. Write your custom class name here (like DinButton)
select table and then go to identity inspector in the right side of the xCode. (left to the Attribute inspector)
Then add your class name in the field "Class".
Thats it.

The storyboard is automatically copied to the new project

I have a project in Xcode, lets name it A, in which I have a story board and several views. I only need part of project A. Hence, I made a new project, B, and made a new UIViewController, with xib, and copied the two UIViews from project A to B.
It looks like this now, where RPM Display and Speed Display are copied (by dragging from xib) from A to B.
AnalogDisplayContainer belongs to the class PD_AnalogDisplayContainer, and we have two outlets in class PD_AnalogDisplayContainer:
#property (nonatomic,assign) IBOutlet PD_AnalogDisplay* speedDisplay;
#property (nonatomic,assign) IBOutlet PD_AnalogDisplay* rpmDisplay;
which are connected to the respective views in xib. (We have exactly the same code in project A.) These UIViews have some UILabels as well, which are automatically copied in project B, and I need them as well. You see them here:
Up to here, the description of what I did. Now, the problem:
I have three outlets in class PD_AnalogDisplay.
#property (nonatomic, assign) IBOutlet UILabel* unitLabel;
#property (nonatomic, assign) IBOutlet UILabel* digitalIntegerValue;
#property (nonatomic, assign) IBOutlet UILabel* digitalFloatValue;
However, so strangely, when I click on the small point beside these outlets, it shows me the connections to story board,
and when I click on the connection, I see the whole storyboard and views from project A.
In addition, these connections are not shown when I click on xib.
I searched in project B, there is no storyboard, or all these things I see in the previous picture, in form of code. So I don't know where it all come from. And I get the run time error:
loaded the "RPMViewController" nib but the view outlet was not set.
Yes, it brings previous reference wherever you copy it.
It is happening because the class name is same in project A and B.
Create class name in project B other than class name in project A or slightly change variable name.
Assign that class to your xib file.
You must recreate the IBOutletes from xib file.
Just copy the interface components not the code in .h file.
Observations:
When I move project A to another location makes trick, reference destroyes.

I can't create an outlet in Xcode 5

I am trying to link a create an IBOutlet for a UIWebView Element, however whenever I hold down control and drag from the Storyboard to the ViewController.h file, nothing happens and an outlet is not created. I already have an outlet in this file, however, I would like to create another one. Whenever I go to the view controller for the previous outlet and hold control and drag the element to the ViewController.h file a new outlet is created. Is there a setting that I have enabled that stops this shortcut from working. Is there another way to create an outlet for ios in Xcode 5.0.1 on Mac OSX 10?
Fixed issue. The class of the view controller was UIViewController not ViewController. This meant that the ViewController.h and .m files were not showing up under Automatic. Once changed I could view the ViewController.h and .m files and create outlets in them.
I recommend not using storyboard, while it is a lot easier to use, it doesn't let you do many things. To create a new outlet, go to where you want to create it (this will most likely be a header file) and then type: IBOutlet yourOutletType *yourOutletName so to create a UIWebView you would type:
IBOutlet UIWebView *myWebView
and to create an outlet, such as a UIImageView, you could type
IBOutlet UIImageView *imageView
just remember to hook it up in your .storyboard file.
Again, I recommend not using storyboard, it IS a lot easier, yet it really has lots of limitations

Resources