Questions tagged [visual-format-language]

Cocoa's language for specifying the layout of control objects on a visual canvas

You use the Cocoa Auto Layout system to define layout constraints for user interface elements. Constraints represent relationships between user interface elements such as “these views line up head to tail,” or “this button should move with this split view subview.” When laying out the user interface, a constraint satisfaction system arranges the elements in a way that most closely meets the constraints.

source

115 questions
162
votes
14 answers

Centering a view in its superview using Visual Format Language

I just started learning AutoLayout for iOS and had a look at Visual Format Language. It all works fine except for one thing: I just can't get a view to center within its superview. Is this possible with VFL or do I need to manually create a…
Christian Schnorr
  • 10,768
  • 8
  • 48
  • 83
33
votes
9 answers

Using Autolayout Visual Format with Swift?

I've been trying to use the Autolayout Visual Format Language in Swift, using NSLayoutConstraint.constraintsWithVisualFormat. Here's an example of some code that does nothing useful, but as far as I can tell should make the type checker happy: let…
Mike Walker
  • 378
  • 1
  • 3
  • 8
28
votes
4 answers

Swift Safe Area Layout Guide and Visual Format Language

I want to use Apples visual format language to constrain a view to the new Safe Area Layout Guide in iOS 11. However, I get an exception: -[NSLayoutYAxisAnchor nsli_superitem]: unrecognized selector sent to instance 0x1c447ed40 //Make View…
11
votes
2 answers

iOS8 Auto layout programmatically pin to relative layout margin

I have an UI element (UISwitch actually, but does not matter really) that has both leading and trailing space pinned to superview in Interface Builder. The constraint looks like this in Xcode 6: The constraint for leading space is the same…
Legoless
  • 10,942
  • 7
  • 48
  • 68
5
votes
4 answers

In AutoLayout can you combine both horizontal and vertical constraints using the Visual Format Language?

In our code in a lot of places, I keep seeing this... containerView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[view]-0-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views:…
Mark A. Donohoe
  • 28,442
  • 25
  • 137
  • 286
3
votes
2 answers

UIView min and max height with Auto Layout

I have a view which is correctly displayed on an iPhone 6 screen, but needs scrolling on an iPhone 5 screen. I am trying to change some Auto Layout constraint to remove the need to scroll on the latter. Here is an attempt to explain my situation…
Pierre Espenan
  • 3,996
  • 5
  • 33
  • 51
3
votes
2 answers

UIScrollview Pull to refresh not working

self.refreshControl = [[UIRefreshControl alloc]init]; [self.objDiscussiontopic addSubview:self.refreshControl]; [self.refreshControl addTarget:self action:@selector(refreshTable) forControlEvents:UIControlEventValueChanged]; -…
3
votes
1 answer

Auto layout error Unable to simultaneously satisfy constraints with UIScrollView

I have a UIScrollView that is to show UIImageViews. The ImageViews are programmatically inserted at runtime based on how many images are saved by the user previously. I get the error below: Unable to simultaneously satisfy constraints. Probably at…
noobsmcgoobs
  • 2,716
  • 5
  • 32
  • 52
3
votes
3 answers

Giving Views the same position in Visual Formatting Language

In Visual Formatting Language is there a way to keep two elements in the same position on one axis? For example I have a UILabel and a UITextField that I want alongside each other horizontally. When laying out the vertical constraints is there…
Jimmery
  • 9,783
  • 25
  • 83
  • 157
3
votes
2 answers

Auto layout VFL: align all trailing in an horizontal constraint

I have four labels stacked one below the previous one but alighning its baseline with the top of its content view, not with a vertical spacing with each other. I do it by code this way [contentView addConstraint:[NSLayoutConstraint…
emenegro
  • 6,901
  • 10
  • 45
  • 68
2
votes
1 answer

Auto Layout broken on iOS 8.1

I'm working with Auto Layout Visual Format Language and using the following expressions: H:|[_tableView]| H:|[_actionButton]| V:|[_tableView][_actionButton(==buttonHeight)]| They work fine in 9 and 10, but in iOS 8.1 we noticed that the layout is…
2
votes
2 answers

Centering Horizontal in visual format language

I have 3 labels which I have placed against each other like in this picture: However right now they are placed against the left side, I wan't them to be placed in the center horizontal. Here is the visual format code for their horizontal…
Fredrik
  • 1,389
  • 1
  • 14
  • 32
2
votes
1 answer

Autolayout Will attempt to recover by breaking constraint

I want to layout a label in the right corner of its superView with 8pt trailing and 10pt from bottom This is my code : let label = UILabel(frame: CGRectZero) label.text = "text goes here" label.textColor = UIColor.whiteColor() …
Bobj-C
  • 5,276
  • 9
  • 47
  • 83
2
votes
2 answers

Manage UITextField's dynamic position using auto layout

My client’s requirement is as follows: I am going to create registration form with around 15 textFields(Pre defined on server). Information of fields in registration fields are coming from server. There are chances that some fields are not required…
iPhone
  • 4,092
  • 3
  • 34
  • 58
2
votes
2 answers

Correct way to change NSLayoutConstraints for orientation with Visual Formatting Language

I have separate arrays of NSLayoutConstraints built using visual formatting strings that I want to use for portrait and landscape orientations. I have tried two methods for switching between the two: activating/deactivating them, and…
alexp
  • 3,587
  • 3
  • 29
  • 35
1
2 3 4 5 6 7 8