I am trying to put a textView inside of a tableViewCell and I am currently using autolayout. I do not understand why my textView is behaving badly (see screenshot below). I don't understand what to add in order to make the preview to display what I have in IB. Here is a screenshot...
Thank you for any help! I am new to Xcode 6. Thanks for any help!!
You didn't add constraints of textView, try to select the textView, in storyboard click the second button on bottom bar and add new constraints to its superview which is cell's contentView.
This is a bug in Xcode 6 at the moment. I have reported it to them.
In the mean time you need to go to that little box down the bottom left of the Storyboard screen (show document outline) and select it. Select your view from in there and select your UITextView. Then resize or do what you need to that way.
Warning
Resizing the UITableviewCell by dragging it and not using the Size Inspector may resize your textview to 0 so you may have to repeat the process.
Related
See the photos below, am I missing a big memo about these changes or is this just more evidence of Tim Cooks lacking focus and neglect of product? What is the solution?
(notice how my table-view cell does not show up on the storyboard, I can't add auto-layout constraints and my table does not reach the bottom of the screen on simulator)
Try:
Select tableView, and the click on autolayout pin.
Set Bottom layout to 0, with pin is On.
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.
When I try to update constraints in Xcode 6.3, I can't because the menu is completely or partially greyed out.
http://hostthenpost.com/uploads/aa150beda71316c338da81c5e301d149.png
Why is this? How do I fix it? The app is a basic, simple Hello World app with two UIImageView elements both sharing heights and widths, and one is constrained 50 from the left, the other 50 from the right. What is wrong with it? How to I make it so I can update the constraints?
Edit: This is when I can see some, but not all of the constraints options.
http://hostthenpost.com/uploads/2d8a3bec6a17524d6f9ca1524c95fb0c.png
That happens when you have a wrong item selected, meaning for example a constraint instead of the view or a subview.
To fix it, just select the view again. Then the options should show up again.
Still some options will be grayed out, if they would have no effect when clicked. For example Update Frames will only be available if there are actually are frames to be updated.
If you clicked on the main view and then on the constraints button, you have to know that you can't adding constraints from the main view in the storyboard, to its superview. You can do this just by code.
If you are trying to change the constraints for any other subviews, please be sure to click with the mouse on the object in the view, and then on the constraints button.
I'm trying to learn how to embed pickers into table views and am starting off nice and simply with a static tableview where I've inserted a UIDatePicker within it.
Unfortunately I'm seeing odd behaviour with how the UIDatePicker aligns within the cell. If I line everything up nice and centred within the storyboard then when i run in the simulator i find the picker displays lower than centred and so looks messy. In the end by eye I've had to add padding to the cell beneath the picker in the storyboard to get it looking reasonable within the simulator when running. As shown in the following images.
Anyone any ideas why the storyboard layout isn't being honoured, or whether there's something I can change which would make them behave themselves better?
Apologies for the image resolution size.
layout of picker and cell in the storyboard
outline of my tableview in the storyboard
picker and cell shown in the simulator
Ok I eventually fixed this... i tried using some auto constraints having snapped the picker to the centre of the cell, sadly this didn't seem to help.
I then cleared the constraints and used the align button to add constraints for horizontal and vertical center in container. Added these constraints and now the picker is behaving consistently between the storyboard and the simulator.
Not sure why when adding it centred using the blue guidelines it didn't default to this sort of behaviour without the constraints but now I know.
Thanks to anyone who took the time to read my question.
I am having a strange situation. I created a very simple screen with some buttons on the storyboard, then when I ran the emulator (is it correct to say simulator or emulator?) it got the spacing wrong for one of the buttons.
I am adding a screenshot. The emulator is to the right of the storyboard screen.
Any idea why this may happen?
I thought it was a problem with the button. And it might have been. But when I took out two lower buttons, I got something even weirder as shown on this screenshot:
Thanks!
It looks like you are using Autolayout, and all your buttons except Investment has a Top constraint while Investment has a Bottom constraint, causing Investment's distance to bottom to stay the same when the screen grows taller.
Click on Investment button, click [Editor -> Pin -> Top space to Superview] in the top menu.
Click Investment button again. Click the second tab from the right in the right panel (the one where you can set frame). Look for a Top Space to Superview constraint, right click and delete. If there isn't one, then XCode did its job. Try running simulator again.
Edit: I just want to say that XCode has a habit of adding Top constraints for you when the view you just dragged into the xib is in the upper half of its container, and Bottom constraints when it's in the bottom half. I know XCode is trying to help but it drives me crazy sometimes.
It looks like you're using a 3.5" simulator and laying out for a 4" device, so the view will be resized.
If you're using autoresize masks, are some of the autoresize masks on your buttons incorrect? You probably want them all to stick to the top of the screen. Check to make sure the autosizing for each of your buttons matches this image. (You'll need to click the "ruler" icon to see these settings.)
I assume that you're using the XCode4 which provides NSAutoLayout as default. When you place an object to the storyboard NSAutolayout automatically creates constrains which layouts the object on the screen automatically for different devices(iPhone4,iPhone5) or orientations(portrait/landscape). Please check NSAutolayout class and constrains. if you want you can remove the NSAutolayout and your objects will be displayed on the simulator normal but in that case you have to manually adjust your objects for different orientations and screens
Hope helps.