Textfield size is not increase in storyboard ios - objective-c

I have a textfield of 100 width but i want the size of this textfield change on different size screens in same manner. i do not want to give % constraint of screen to increase size. for example in 6s textfield size is 100 but on 7 size should be change on the basis of screen size.

If you want to use constraints, you have to manually change its value accordingly to screen size. You can drag and drop your constraint properties as outlet
And you can change the constraint by accessing its constant property
self.viewWidthConstraint.constant = 20 //Or desired value

Related

NSCollectionViewGridLayout in a single row with resizable collection items which maintain an aspect ratio?

I have a NSCollectionView which uses a NSCollectionViewGridLayout to create a single row of collection view items. The row can have one or more items and can scroll horizontally is needed, i.e. one row, unlimited columns (one item per column).
The collection view items have a minimum size of 240x160 and have an aspect ration constraint of 3:2 (the width is 1.5 times the height). There is no maximum size.
All the spacing/insets are set to zero so that the items are next to each other horizontally, starting at the left-hand side of the collection view (though ideally I'd like to center the items horizontally if the total width of the items is less than the width of the collection view.)
The collection view is in the top half of a split view. When dragging the divider up/down (vertically), I'd like to resize the collection view items while maintaining the aspect ratio. The problem is that the aspect ratio constraint conflicts with the leading/trailing constraints and causes a constraint exception.
1) I've tried removing the leading/trailing constraints from the collection item view, but then the items are not flush together. I can't have gaps between the items and I can't the items overlapping each other.
2) I've tried removing the aspect ratio and the items resize correctly but don't maintain their aspect ratio.
3) I've also tried setting an aspect ratio on the collection view width such that it equals the height of the collection times the number of items times the aspect ratio, but wasn't able to get it to work correctly (and it seems kind of hack-ish). I also tried a custom layout object but I ran into different errors.
3) I was considering, but didn't try, de-activtating the aspect ratio constraint when the drag starts, and re-acivating the constraint when the drag ends but wasn't sure if this would work (it seems kind of hack-ish).
// setting up the grid layout
NSCollectionViewGridLayout* layout = [[[NSCollectionViewGridLayout alloc] init] autorelease];
layout.minimumInteritemSpacing = 0.0;
layout.minimumLineSpacing = 0.0;
layout.margins = NSEdgeInsetsMake(0.0, 0.0, 0.0, 0.0);
layout.maximumNumberOfRows = 1;
layout.maximumNumberOfColumns = 0;
layout.minimumItemSize = NSMakeSize(260.0, 160.0);
layout.maximumItemSize = NSZeroSize;
self.theCollectionView.collectionViewLayout = layout;
(not shown are the constraints in the collection view item xib file)
The desired result is to have:
a) User resizing a single row of collection view items by dragging a split view divider, and they maintain their aspect ratio while being resized.
b) Ideally, collection view items would be centered horizontally in collection view if the items don't scroll horizontally.

multiple line UILabel is truncating

I want to display status on a UILabel. I want it to wraparound at word breaks if it's too long, and I want font size to shrink if not enough room in the UILabel.
UILabel is created in storyboard, and its Lines = 2, and Autoshrink is Minimum font Scale 0.5
But I can't make this happen. Text keeps truncating.
I got it working:
In storyboard:
1. stretched UILabel vertically bigger
2. Lines=0
3. Line Break = word Wrap
4. Autoshurink = Fixed Font Size

UITableViewCell nib with several constraint scenarios

I have a UITableViewCell nib that depending on the data it can show an image or not.
Below, the cell has 2 labels and at the right most the imageView. What I want to do is to remove the imageView (if no image is present on the data) and extend the Label all the way to the right.
Is there a way to have several constraint scenarios on the nib that I could activate/ deactivate?
Constraints on label1
leading, 2. center vertically in container, 3. fixed width
Constraints on label2
Leading space with label1, 2. Center vertically in Container
Constraints on imageview
Trailing space, 2. Top space, 3. Bottom space,
Width constraint : width <= 50 (When there is no image then width will automatically get zero),
Horizontal space between
label2 and imageview = 0 (priority = 250)
See the below GIF:

FlowPane height change measurements

I have a Stage as a form with a FlowPane. I just add Strings to the FlowPane. The main target with the flowpane is to create a "Tag" like control. This Tagcontrol is in the middle of the form.
Without or only one/two items the FlowPane should only have the same height as a TextField. When adding more and more Strings the FlowPane should increase its height till a certain maximum. While increasing the height of the FlowPane till its maximum also the height of the Stage should grow.
Now: how do I get the needed delta-height of the FlowPane when adding more and more items. For example on the first row I have two strings, on the second row i could right 5 strings depending of the string-length. If I have the delta i can use this to increase the height of the Stage easily.. but I am stuck with this calculation of flowheight-change.
I just messed around somewhere else in the code. You can just bind the height of the flowpane and you're good.

How to do multiline UILabel in ios?

I'm dynamically populating the title (UILabel). Sometime it's bit too long and IOS squeeze the font to fit in the width. Is there a way to do multiline with using same font size?
Set adjustsFontSizeToFitWidth to NO and numberOfLines to 0.
numberOfLines Docs
This property controls the maximum number of lines to use in order to
fit the label’s text into its bounding rectangle. The default value
for this property is 1. To remove any maximum limit, and use as many
lines as needed, set the value of this property to 0.
If you constrain your text using this property, any text that does not
fit within the maximum number of lines and inside the bounding
rectangle of the label is truncated using the appropriate line break
mode.
When the receiver is resized using the sizeToFit method, resizing
takes into account the value stored in this property. For example, if
this property is set to 3, the sizeToFit method resizes the receiver
so that it is big enough to display three lines of text.
You may additionally want to specify the lineBreakMode unless the default UILineBreakModeWordWrap is suitable for what you want.
Use UILabel properties as below :
textLabel.lineBreakMode = NSLineBreakByWordWrapping;
textLabel.numberOfLines = 0;
Yes, you set the numberOfLines to 0, and the .lineBreakMode to UILineBreakModeWordWrap in code, or the equivalents if your label is defined in IB.
I just used LineBreak mode to Truncate Tail and setNumberOfLines to 0 and its working for me.
the label is of multiline now.