autolayout

AutoLayout constraints to UITableViewCell contentView not respected

和自甴很熟 提交于 2019-12-20 02:13:29
问题 I'm trying to create dynamically resizing table view cells. I accomplished the resizing by using this answer, which is very detailed and helpful. However, the maximum width for the label is not being calculated correctly in heightForRowAtIndexPath . My cell currently only has one label in its contentView , with constraints set to pin all the label edges to the contentView edges. Here's what I have in IB The cell size is being calculated with an offscreen cell in heightForRowAtIndexPath using

AutoLayout constraints to UITableViewCell contentView not respected

五迷三道 提交于 2019-12-20 02:13:08
问题 I'm trying to create dynamically resizing table view cells. I accomplished the resizing by using this answer, which is very detailed and helpful. However, the maximum width for the label is not being calculated correctly in heightForRowAtIndexPath . My cell currently only has one label in its contentView , with constraints set to pin all the label edges to the contentView edges. Here's what I have in IB The cell size is being calculated with an offscreen cell in heightForRowAtIndexPath using

Alternative iOS layouts for portrait and landscape storyboard

两盒软妹~` 提交于 2019-12-19 19:56:35
问题 I need to design different layouts for landscape and potrate I know how to design using .xib file but don't get how design different layout using storyboard. I want something like This but using storyboard. please help me. 回答1: You will need to create different views or different constraints for each screen layout. You can select the current screen layout here: And you can determine whether a view is going to be present (installed) in that screen layout here (look at the bottom): It should be

Autolayout in UITextField: Auto Layout still required after executing -layoutSubviews

会有一股神秘感。 提交于 2019-12-19 17:34:07
问题 I'm subclassing UITextField to add a label on the left side. I'm using autolayout to layout the label. However, I keep getting this crash: Here's how I am doing my layout code: - (void)updateConstraints { self.segmentLabel.translatesAutoresizingMaskIntoConstraints = NO; NSLayoutConstraint *constraint; constraint = [NSLayoutConstraint constraintWithItem:self.segmentLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeHeight multiplier:1

Proportional height (or width) in SwiftUI

↘锁芯ラ 提交于 2019-12-19 09:11:39
问题 I started exploring SwiftUI and I can't find a way to get a simple thing: I'd like a View to have proportional height (basically a percentage of its parent's height). Let's say I have 3 views vertically stacked. I want: The first to be 43% (of its parent's height) high The second to be 37% (of its parent's height) high The last to be 20% (of its parent's height) high I watched this interesting video from the WWDC19 about custom views in SwiftUI (https://developer.apple.com/videos/play

Proportional height (or width) in SwiftUI

北城以北 提交于 2019-12-19 09:10:31
问题 I started exploring SwiftUI and I can't find a way to get a simple thing: I'd like a View to have proportional height (basically a percentage of its parent's height). Let's say I have 3 views vertically stacked. I want: The first to be 43% (of its parent's height) high The second to be 37% (of its parent's height) high The last to be 20% (of its parent's height) high I watched this interesting video from the WWDC19 about custom views in SwiftUI (https://developer.apple.com/videos/play

Autolayout a UIScrollView to fit content including subviews and grouped tables

我与影子孤独终老i 提交于 2019-12-19 09:04:44
问题 I am trying to present information about an object grouped into sections. It may be long, so each section uses a view to visually separate the areas and it is all in a scroll view. The first subview has a text field that does resize to fit the text, and its parent view also resizes to fit the text field. The second subview has a grouped table to display data. I want all of the data in the table to appear and there should be no table scrolling. The third subview has more information but its

iOS 8 Orientation change: Keyboard frame does not display correctly

末鹿安然 提交于 2019-12-19 08:17:11
问题 This is only an iOS 8 problem, the keyboard displays correctly in iOS 7 with device orientation change. My application supports both portrait and landscape orientation and uses autolayout. If I push a UIViewController subclass that contains a UITextField subclass onto a navigation stack and the UITextField becomes the first responder in portrait orientation then the default keyboard displays correctly. However, if I rotate the device to landscape orientation then the UIViewController subview

Regular / Regular position sizing constraints for all iPads, including iPad pro?

怎甘沉沦 提交于 2019-12-19 07:49:57
问题 I've used multipliers in my constraints, to size my views. However in my constraints for position I've used values, which I change for different sizing classes. However using regular / regular sizing classes for iPad Pro it's positions values aren't big enough, but for other iPads it's fine. I seriously don't have to add positioning views with multipliers to provide percentage spaces for all my views as well do I? 回答1: What we're after is to set the margin between the top of the screen and

Why isn't UIButton returning correct constraints?

两盒软妹~` 提交于 2019-12-19 05:44:28
问题 In my code below: I have 5 buttons added into a vertical scrollView. Each button is constrained to the scrollViews's top + 20 ,leading, trailing edges and its height. I have created a b1HeightConstraint variable. It's there to hold the heightConstraint of the b1 button. In a button click, I'm trying to remove this constraint. Yet I'm facing an odd issue: When I log the constraints I only see 2 constraints, even though I've added 4 constraints to it. My the view debug hierarchy is like below: