Suddenly xcode hided the views in interface builder Storyboard - iphone - ios

The app was working normally, till I committed my code using Git for pushing the code online. The views were hidden from the interface builder (storyboard) suddenly.
It shows the views this way:
the interface builder does not show the faded views as well:
I tried to check for the source code of the storyboard but nothing looks wrong. what can be a possible error that cause this problem ?

You are looking at what happens when you have designed your views in a particular size class and then, when you look at the storyboard, you are not in that size class.
For example, let's say you happened to be in size class H:Regular W:Compact when you put "top line" into its superview in Interface Builder. At that time, the bottom of your Interface Builder canvas would have shown something like this:
That blue is supposed to be a warning that you are working in a specialized size class! But you, I am postulating, paid no attention to that warning.
Okay, so now you come back later and you are in size class H:Any W:Any. What you are showing in your screen shots is just what I would expect to see.
You would also see something like this at the bottom of the attributes inspector when you select one of the views:
That would show that you've accidentally installed your view in a specialized size class and not in the size class you are in.

Related

Size inspector not working in Xcode: there are no options showing

I have added a UIViewController in the storyboard. And when I tried to change its size, there are no options showing in the size inspector. The attributes inspector also shows nothing. The xcode version that I am using is 9.4.1. It was working before.
Sometimes it happens with the Xcode, it seems the bug in it.
The solution is
Just close the current tab and open a new tab. Now Size inspector, attribute inspector, etc. will be shown.
Sometime its Xcode Bug, Just close current tab and open new … Hopefully you will see the Size Inspector.
Work with View Controllers
If you will still face the problem follow the below instructions to test your Xcode is working properly and you are using ode in proper way.
For this, you’ll use an image view (UIImageView), a user interface
element that displays a picture.
To add an image view to your scene
Open your storyboard, Main.storyboard.
Open the Object library in the utility area. (Alternatively, choose
View > Utilities > Show Object Library.)






In the Object library, type image view in the filter field to find
the Image View object quickly.



Drag an Image View object from the Object library to your scene so
that it’s in the stack view below the button.






With the image view selected, open the Size inspector  in the
utility area.

Recall that the Size inspector appears when you select the fifth
button from the left in the inspector selector bar. It lets you edit
the size and position of an object in your storyboard.



Size class initially unknown

I am trying to setup my UI on my universal app. I have a storyboard setup with size classes, a fairly simple UI. I have my view controller with a view in. Inside this view, I draw a chart so this can only be updated using setFrame.
This is where my problem begins. I set my graph to be the screen width. However, when the view initially runs, the size class seems to be unknown.
As the default 'Any' size in my storyboard is 600x600. My view thinks it should draw 600 wide on my iPhone, which clearly isn't this wide.
It is only after I physically move the iPhone to toggle an orientation change, that it updates and recognises the correct size.
So my question is, how do I prevent this problem? I need my UI to know what size to be from the get go, not just after the user rotates their iPhone.
However, when the view initially runs, the size class seems to be unknown.
It is unknown to the view and the view controller, because at that time the view controller is not yet part of the interface and has no environment. But it is not unknown to UIScreen.mainScreen(). So if you need this information very early, that is who to ask.
However, as you've been advised in a comment, it also sounds like you may simply be doing this too early. Nothing in a view controller's view, including the view itself, has achieved its actual size until viewDidLoad or later.
There are two to prevent this problem
(1) Load your entire method in
-(void)viewDidAppear:(BOOL)animated
{
}
(2) Do the following step
Go to file Inspector
Uncheck "Use size classed

Setting Modal Presentation Style causing views to disappear (Xcode 6)

I have set up my view in interface builder. I am using auto layout which has been set up also.
If I present my view with the following code:
GlossaryViewController *glossaryViewController = [[GlossaryViewController alloc] initWithNibName:#"GlossaryViewController" bundle:nil];
glossaryViewController.delegate = self;
glossaryViewController.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:glossaryViewController animated:YES completion:nil];
Then everything works fine. However if I change modalPresentationStyle to a smaller style such as UIModalPresentationFormSheet then none of my views are visible when the view appears.
I have even tried testing it with just a UIImageView that is set to hug the four edges. Even this disappears.
Before I upgrade to Xcode 6 I had created similar views that still work fine. This has only occurred when creating a new xib.
Has anyone else had similar issues?
After deleting the app, deleting the troublesome nib, doing a clean, restarting xcode and then recreating the xib I still have not be able to get this to work. This was after attempts at changing the size of the view, orientation and playing around with auto layout.
The behaviour is rather odd. Sometimes a single view might show but adding any others by it does nothing.
I have hopefully found a work around for now. If you do as follows:
Click on files owner and then go to the 'Show file inspector' tab.
Next look for 'Interface builder document'. Under this heading is 'Opens in'. Change this from 6 to 5.1.
The following popup appears. (WARNING: if seems once you have clicked 'Disable size classes' there is no going back. So make sure it's what you want to do):
Select the option you want to keep. So if the xib is just for iPhone then select iPhone. This will then give you back the way it was in xcode 5. Basically it's converting it back to a xib that handles either iPhone or iPad and not both.
Look forward to hopefully someone being able to explain what I am doing wrong or if there is some sort of issue with interface builder at this moment in time. Be good use the new interface builder instead of switching back to xcode 5.1 xib interface.

How to connect custom UIView in interface builder using storyboards?

I want to use an F3BarGauge ( http://www.cocoacontrols.com/controls/f3bargauge ) in my iOS app and I want to use a .storyboard for my UI design.
I managed to achieve this programmatically by writing code into the view controller's loadView: method, which creates the instance of the F3BarGauge and adds it to the view via [self.view addSubview:myBarGauge]; .
However, now I can't see the F3BarGauge at all in the preview in Interface Builder and therefor I also can't adjust the size or position of the F3BarGauge from there. I can only do this in the code. Moreover, I think it is confusing for my colleagues if I create parts of the UI elements automatically through the .storyboard and some in my own code.
I would like to find a solution for both of these disadvantages.
It is not important for me to see the actual custom UI element's content (in this case the F3BarGauge) in Interface Builder. If the frame of the F3BarGauge's area is displayed in Interface Builder and I can move and resize it, then I'm happy with the solution.
I do not have an example for this approach, because the example from the author of the F3BarGauge uses a .xib file and not a .storyboard.
I'm relatively new to iOS programming and Xcode / Interface Builder. Maybe there is a better way to achieve what I want than how I imagine my solution.
I don't think there is a way to see the F3BarGauge in IB, but you can add a UIView as a subview of your main view in IB, size and position it as you like, and then in code, add the F3BarGauge to the subview.
After Edit: Actually, after looking at the author's demo project, you can see it in IB. Just copy and paste his view from the demo project into a view controller (after deleting the default view first).

Why are two different UIToolbars, defaulting to different styles?

Consider the following two toolbars that are in the same project of mine:
Notice that these toolbars look different? The problem is that they were both created by dragging and dropping them into IB, and I didn't change any of there associated properties. All that I did change was adding the flex controller, and change the text on the initial UIButtonBarItem. Other than that, these Toolbars have not been modified and, furthermore, I've verified that their properties are exactly the same in the Attribute inspector.
How or why are they different? Furthermore, how can I get the first, bluish UIToolbar to look like the grey one since the available Black Opaque and Black Translucent styles look nothing like the grey one?
Am I missing something? This doesn't make any since.
I've found why this is happening but I'm a bit clueless on how to change this. See this, new question regarding a fix for this issue.
These Toolbars are changed due to internal Xib settings that are specified when the Xib is created. In the first example, when I created the UIViewController I must have unchecked the Target for iPad check box, even this is for an iPad project.
This changed the default size of the initial UIView that was in the Nib. I always cut off the statusbar and set the view to be freeform in sizing as soon as I create a UIView within a Xib file, so I can never tell by looking at my views whether they were targeted for the iPad or not.
When I created the second UIViewController object, I checked the Targeted for iPad option. Now, my toolbar is styled with a grey tone.
The lesson learned is obvious-- if you want consistency in the default style of your objects that you pull from the IB Toolbox, be sure to create your UIViewControllers, specifically targeted for the iOS device. If you've made the same mistake that I have, follow the linked question above for how to revert your UIViewController and Xib file to the other style of View Controller.

Resources