xib shows blank box even we have many view and other designing in Xcode - ios

I am using xib and it just shows blank square box even I have done designing and added many views.
Please check attached image no matter its huge designing or just 1 - 2 labels it shows the only square box.
but if I run it will woks perfectly in the device.
My Xcode version is 10.2.1.

You can try one of the following options to debug this issue:
Drag the main view to increase its size and give it some background color which can be seen easily(like red).
Try populating the labels with text in the XIB so that they take up some space and expand the views dependent on them.
Give height constraints to all the views to check if they are visible.

Related

IOS: Storyboard showing UIButton in Different place when selected

Something weird has happened to my storyboard. Some buttons and labels are not showing where they should based on their coordinates and also how they appear when the app runs.
In the following picture, when selected the outlines of the elements are appearing above where they do in the actual storyboard.
There are no constraints and I'm not using autolayout. The storyboard just seems to have gotten out of whack.
I have tried closing the progam and reopening and also cleaning project without success.
Thanks for any suggestions on how to get buttons/labels to appear where they should based on their x,y, width, height settings.

storyboard constraints (Xcode)

I'm new to programming and I'm trying to work with Xcode. I have no experience. I'm trying to make an app with Xcode. I'm done with the code, the only issue i have is with the storyboard constraints. I need some one who can help me to set them up.
So, i have 28 buttons as you can see in the picture, I want to keep the size of 65x65 pixels. that means that the distance between them should vary in different device sizes(4inch, 4.7inch and 5.5inch). i also should mention that i want it to be only in portrait view and only for iPhone.i hope someone can help because I'm to noob for this, I've searched a lot on the internet but I'm not able to do it.
UIStackView (iOS 9+)
UIStackView was introduced in iOS 9, which is very useful in your case.
Edit: Before getting started, make sure to have size classes to be w Any, h Any, this will make thing easier.
To use this, search UIStackView in your utility panel.
Drag an drop a Vertical Stack View on the view of your view controller and set the constraints so it spans the whole screen.
Select the stack view we just placed and set the distribution to Fill Equally.
Drag and drop a Horizontal Stack View onto the vertical one.
Select the horizontal one and set the distribution to Fill Equally.
Place your buttons in the Horizontal Stack View.
Copy and paste the horizontal stack view multiple times based on number of rows you want.
That's it.
You can control the buttons' background images to make it smaller (65px), or you can place a view as its' parent then align horizontally/vertically to place it to the center, like this:
Orientation
If you'd like to lock the orientation throughout the app, go to the settings of your project.
Sample project
I made a sample project for this question, you can check it out here: https://github.com/cyhsutw/UIStackView-example

iOS, View width - out of bounds

I'm having an issue with storyboard (least bit surprised).
I have one ViewController which holds a container view along side various image views. Naturally, the image views selected determine what is displayed in the container view.
My issue is that when simulated on iPhone 6 plus, i have the container not meeting the edge of the window, thus creating a gap (See below - Left hand side).
My constraints are as seen below
As they appear in storyboard
I'm lost as to how i am supposed to do this easily & correctly. Any suggestions?
Delete those two constraints and then add them again, this time unchecking "Constrain to margins".

how to use a xib file for all device sizes in xcode

I would really appreciate if someone can tell me about how can I use one xib file to target different device sizes. I am creating a Custom Keyboard extension using a xib file having view property of "freedom". The view loads great in iPhone 4,4s,5 and 5s. However whenever i run the app for iPhone6 or 6s there is a blank space at the right hand side. (please see the attached screenshot, missing area is shown in red), looks like the keyboard doesn't stretch according to the screen size.
How can i fix that? I disabled the auto layout and use size classed option. I am a very new developer and coding using swift.
Thanks a lot
I would use autolayout for this, I would not disable it in the xib. Its also the reason as to why you have a space at the end of your view, as it is not expanding automatically to the sides, it has been set statically e.g. setting the frame.
I would have a look at this link but in the mean time I would re-enable autolayout then with your keyboard view container ctrl click drag to your main view and select Leading(left), Trailing(right), Top & Bottom Space to Container. Below is the popup menu from ctrl clicking then select the triangle at the bottom right then Update Frames, this will relayout the view. It might not layout the keyboard keys correctly but its is a start.

IOS - How to get my text view object information to scroll on view?

I am using Mac OS X Lion 10.7.5 and XCode Version 4.6.1 (4H512),
I have looked at these answers on stackoverflow to try to figure out my question
-cannot make a text view scroll - xcode 4.3
-also posts that looked possible, when I searched on "scroll text in UITextView" within stackoverflow
Within Interface Builder I cannot figure out how to make information in a UiTextView object scroll within the iPhone simulator*. To resolve this challenge, I have made the most simple prototype project I can think of, just a view and one text view object on it, filling the text view object with a stream of text simply typed in via interface builder. For this most basic sample I'm using to sort out my problem, I have not done anything programatic. (Please note that I am aware of StoryBoards and have begun working through a book to learn to use them, but I would like to finish my first prototype app using what I’ve already learned and fully complete one project before I move onto my next project using StoryBoards.)
When I run this in the iPhone simulator, I see the sample information in my text view object come up. As I expected not all the information displays, due to my sizing the box a little too small on purpose. But I cannot flick or arrow down, or in any other way view the rest of the text information within the simulator. Nor do I see scrolling bars anywhere on the view. The information is just frozen in/on the view.
Inspector Settings
Identity Inspector
"Accessibility" Tested both with Enabled checked and not checked
Use Auto Layout is NOT checked
Attributes Inspector
Behavior Editable box not checked
Scroll View Area Checked ‘show horizontal scrollers, shows vertical scrollers and also scrolling enabled” The rest of the scrollers box are not checked
Bounces is checked
Zoom min and max are both 1
Touch all boxes checked- bounces zoom, delays content touches, cancellable content touches
View mode is ‘scale to fill”
Interaction ‘multiple touch’ is checked
Drawing checked opaque, clears graphics context, clip subviews, and autoresize subviews. Only ‘hidden’ is not checked
Size Inspector
I played around with the ‘scrolling insets’ boxes changing them from the default (I think it was 0 or 1), just to see if I noticed anything. I think maybe that I see some shadowy marker type lines in Interface builder in the area where I might expect a scroll bar when I make these changes, but no change in appearance within the simulator.
I cannot figure out why my actual iPhone device with everything up to date, is now not working as a test device, but I believe that is a separate challenge
how about wrapping you uitextfield in a uiscrollview. Make the scroll view the dimensions you currently are setting the uitextfield to, then allow your uitextfield to scale to the size of the text.
This is one of those questions that solved itself eventually. After twice creating the most basic app, with no programmatic bits just interface builder and a textView object with all the defaults the scrolling worked. The only reason I can think of that it might not have scrolled as expected the first time through may have had to do with placement of the textView object on the view. I wonder if it overlapped the bottom of the view and maybe that messes something up.
Just one of those situations where I had to keep plugging away, trying what seemed like the same thing repeatedly,set in the Inspectors, and suddenly, like magic, it worked. Except no magic involved.

Resources