autolayout

How can I display views using autolayout constraints in Xcode playground?

ぃ、小莉子 提交于 2019-12-30 04:20:25
问题 I am trying to display views configured with autolayout constraints in XCode playground , but it doesn't seem to work. It's like playground ignores the constraints completely, and I can't find information about this issue anywhere. Here's the code I tried: let view = UIView() view.frame = CGRectMake(0, 0, 400, 200) view.backgroundColor = UIColor.lightGrayColor() let label = UILabel() // I can only see the label if I set a frame // UILabel(frame: CGRectMake(0, 0, 200, 50)) label

Autolayout Error with UITableView

孤人 提交于 2019-12-30 04:03:22
问题 I have a TableView and I specify the height for each cell using the delegate method tableView:heightForRowAtIndexPath: . When I rotate the view I get this error that I don't quite understand. It can't satisfy the constraint below and breaks it to continue. "<_UIScrollViewAutomaticContentSizeConstraint:0x8e8d040 UITableView:0x9423400.contentHeight{id: 213} == -1568.000000>" Does anyone know what is happening and why I'm breaking this constraint? 回答1: UPDATE : This issue is no longer relevant

Autolayout Error with UITableView

谁说我不能喝 提交于 2019-12-30 04:03:05
问题 I have a TableView and I specify the height for each cell using the delegate method tableView:heightForRowAtIndexPath: . When I rotate the view I get this error that I don't quite understand. It can't satisfy the constraint below and breaks it to continue. "<_UIScrollViewAutomaticContentSizeConstraint:0x8e8d040 UITableView:0x9423400.contentHeight{id: 213} == -1568.000000>" Does anyone know what is happening and why I'm breaking this constraint? 回答1: UPDATE : This issue is no longer relevant

UIScrollView AutoLayout Vertical Only

为君一笑 提交于 2019-12-30 03:41:39
问题 I want to get the AutoLayout working with the UIScrollView and am having a little trouble with it. Here is what I did: Add a UIScrollView inside the Main View with frame: [top: 0, left: 0, width: 320, height: 568] Add UIView "ContentView" inside the UIScrollView with frame and bgcolor black: [top: 0, left: 0, width: 320, height: 568] Setup UIScrollView constraints: [top: 0, bottom: 0, left: 0, right: 0] Setup "ContentView" constraints: [top: 0, bottom: 0, left: 0, right: 0] Align the items

UITableViewHeaderFooterView subclass with auto layout and section reloading won't work well together

心已入冬 提交于 2019-12-30 02:43:11
问题 I am trying to incorporate auto layout into my UITableViewHeaderFooterView subclass. The class is pretty basic, just two labels. This is the complete subclass: @implementation MBTableDetailStyleFooterView static void MBTableDetailStyleFooterViewCommonSetup(MBTableDetailStyleFooterView *_self) { UILabel *rightLabel = [[UILabel alloc] init]; _self.rightLabel = rightLabel; rightLabel.translatesAutoresizingMaskIntoConstraints = NO; [_self.contentView addSubview:rightLabel]; UILabel *leftLabel = [

how to show multiple lines in MKAnnotation with autolayout?

ⅰ亾dé卋堺 提交于 2019-12-30 02:29:07
问题 i am using mapkit how i can multiple line in MKAnnotation view . Every annotation there has title and subtitle. how i show sub title with multiple line with the help of auto layout ? i found it's Answer .plz try my answer. we just need to do code in - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation { } here i show the idea how to use autolayout with MKAnnotation . 回答1: extension for adding multiple lines: import MapKit // must import MapKit for

Removing and re-adding a subview with autolayout

血红的双手。 提交于 2019-12-30 00:38:33
问题 When using autolayout, my understanding is that removing a subview ( while holding a reference to it of course), the removed subview still knows its autolayout constraints. However, when adding it back to the super view later, the subview no longer knows its frame size. Rather it seems to get a zero frame. I assumed that autolayout would auto size it to meet the constraints. Is that not the case? I thought auto layout meant don't mess with frame rects. Do I still need to set the initial frame

Hiding a UIView using AutoLayout constraints

时光总嘲笑我的痴心妄想 提交于 2019-12-29 10:19:12
问题 From time to time I have a subview that I would like to remove from a layout. Not only should it be hidden, but it should not be considered part of the view's 'flow', so to speak. An example: I am looking for a strategy to hide the orange view programmatically. The layout of the boxes, and their content, is via autolayout. Two things to note: the orange box is defining its vertical height based on the content, plus some top/bottom offsets for margins. So, setting the labels' text to nil will

How to manage the gap between two views in auto layout

冷暖自知 提交于 2019-12-29 09:41:33
问题 I am using auto layout for my ViewController I know how to define the gap between two views using constraints programmatically. What I want to do now is when the screen size increase, increase the gap also. Because my UIViews are positioned properly in iphone 4s and 5s but in 6 and 6 plus they are positioned in a small area of the screen. I know adding multiplier we can set the aspect ratio of a view but, how to increase the gap between 2 views when the screen hight increase. UPDATE Let say

TopLayoutGuide and BottomLayoutGuide Deprecated in iOS 11

二次信任 提交于 2019-12-29 07:12:17
问题 UIViewController 's topLayoutGuide and bottomLayoutGuide are deprecated in iOS 11. What should be the replacement? 回答1: Previously in your UIViewController : customView.topAnchor.constraint(equalTo: topLayoutGuide.bottomAnchor).isActive = true customView.bottomAnchor.constraint(equalTo: bottomLayoutGuide.topAnchor).isActive = true Now you should use: customView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true customView.bottomAnchor.constraint(equalTo: view