How to remove xib file for UIViewController class? - ios

I want to remove xib file for UIViewController classes. Please let me know, If any one know how to remove or delete xib file.

You can just delete the .xib file,
If you want a new .xib for your view controller, create new xib
Then give ViewController as File's Owner's Custom Class,
Finally, link the ViewCrontroller's view and .xib

I'd like to add that the labels and everything I had placed in the file still showed up in the Simulator after I had deleted my .xib
It seems, Simulator caches the contents and I had to delete the app from inside the Simulator to force it to totally rebuild. Worked after that.

Related

Animated UIActivityIndicatorView on LaunchScreen.xib

With the new xcode one is able to present a .xib named LaunchScreen on launch, which is great. I added a UIActivityIndicator to this very file, but I am not able to animate it. How can I accomplish this? Do I need to add a code file just for this?
What I've tried
Selected 'Animating' in the 'behavior' section of the xib

IOS Custom UIView doesn't show

I'm sorry but i'm still a bit dumb in UIViews and creating a custom one.
I have a custom view and a xib file that are connected through the XIB IB.
I want to add this view to the storyboard.
What you see in this picture is an empty view which i've connected to the custom view class
When launching the app - i see the exact same view without my custom view being loaded.. what am i missing ?
It is not enough to just link your xib view to the storyboard through the view class name. You should copy the view from your xib (open your xib, select the root view and copy) to your storyboard view controller (select the parent view and paste). You can even open (double tap the xib file in the navigator) your xib in a new window and do a drag drop to the story board. Note that all the property wirings and constrains that you had defined in the xib will be retained when you copy paste your view from xib file.
The answer is actually pretty simple.
I had a recursive init process - meaning that although i did over initWithCoder method, in the xib file, i've set the view class to be my class.
What i should have done is to make my xib file's owner to be my class instead.
And then all the loadFromNibName worked perfectly in my initWithCoder!

Copy and paste storyboard controller into xib file. Supported or not?

I want to refactor out a storyboard controller to a separate xib, for better reusablity.
The controller extends UITableViewController.
I can select the controller in the storyboard, hit Cmd-C, create an empty xib file using the New File wizard, and finally paste the controller into the xib.
It seems to work ok. The UI elements are there, the outlets are there, etc. It forgets the orientation and the size (portrait, Retina 4-inch), but I can easily set that in the properties pane to the right in xcode.
However when trying to use this xib I get a crash with error message:
loaded the "MyController" nib but the view outlet was not set.
When I try to connect Files Owner to the table view (which is the top view in a controller extended from UITableViewController), xcode won't let me connect them.
My question: Is it unsupported to copy-paste a controller from a storyboard to a xib?
You are most likely jamming a tableViewController into a nib and there is no outlet to hook the view to. When you do Ctl-C in the storyboard make sure you copy the UITable not the UITableViewController. If not you can try to manually create the outlet in the controller but you might have to jump through hoops to make it work.

How do I know which xib is the first one to load?

I am researching a huge Xcode project, how do I know which xib is the first xib be loaded by IOS?
In main.m, I can only know the main delegation file, but how to find the main.xib.
BTW, I search the {project}-info.plist, but found nothing.
Addtion, I know which file is the rootviewcontroller.
From your description the project doesn't use storyboard(s), so the initial window and root view controller are created by the app delegate. This may or may not use an XIB file (you'd need to check the implementation if the view controller class).

How to copy and paste Xib file with xCode Interface Builder

I need to create a new xib file and want to use an existing xib to base my layout off of. What's the best way to create the new xib file? If it was Android I'd copy and paste the xml and then start tweaking but with the IB I don't have that option (right?).
I've tried two things so far, (1) copying and pasting the file in xCode but the option isn't there and (2) copying all the UI elements from the old xib and pasting them into a new blank xib. This copies all the UI objects, but doesn't maintain structure or spacing at all. What's the best way?
Just make a copy of NIB file, rename it and add to the same Xcode project. Change File Owner class in new nib if needed.
When I need to do this I convert the file to a .nib (shift click the file and delete .xib and add .nib) then you can see all the XML copy that. Then I make a new .xib and convert that to .nib and paste the XML then you can convert them both back to a .xib. You can also Right click the file and navigate to View As > Source Code
If Storyboard is used: Add a new UIViewController to the storyboard. Remove its main view so that the view controller is empty. Set the Class of the view controller (in the Identity Inspector) to that of your nib's File's Owner. Also make sure the .h and .m files are added to your project already.
Now open the nib, select the top-most view and press Cmd-C to copy it to the clipboard. Switch to the storyboard, select that new, empty view controller. Press Cmd-V to paste the contents of the nib into this view controller.
You may have to reconnect all the outlets and actions, but at least you don't have to do the layout again.

Resources