autolayout

Self-sizing UICollectionView with UITableView with dynamic header as a cell

六眼飞鱼酱① 提交于 2021-02-11 13:07:41
问题 I have a problem with making a self sizing UICollectionView with a cell that contains UITableView with a header that has a label with dynamic height. Can someone point me out to what I need to change in the attached sample project? You can see on the screenshot that the table does not fit the view as the cell's height is currently manually set. import UIKit class ViewController: UIViewController { static let section1 = "section1" static let section2 = "section2" private weak var

Self-sizing UICollectionView with UITableView with dynamic header as a cell

ε祈祈猫儿з 提交于 2021-02-11 13:05:38
问题 I have a problem with making a self sizing UICollectionView with a cell that contains UITableView with a header that has a label with dynamic height. Can someone point me out to what I need to change in the attached sample project? You can see on the screenshot that the table does not fit the view as the cell's height is currently manually set. import UIKit class ViewController: UIViewController { static let section1 = "section1" static let section2 = "section2" private weak var

Vertically rotated UIPageControl taking too much space

冷暖自知 提交于 2021-02-11 12:21:46
问题 I used CGAffineTransform to rotate a horizontal UIPageControl vertical. But when I added it besides my collection view it's taking too much width. And when I add a width anchor on it, the UIPageControl disappears. noticesPagingIndicator = UIPageControl() let angle = CGFloat.pi/2 noticesPagingIndicator.transform = CGAffineTransform(rotationAngle: angle) NSLayoutConstraint.activate([ // noticesPagingIndicator.widthAnchor.constraint(equalToConstant: 30), noticesPagingIndicator.leadingAnchor

UIScrollView ignores frameLayoutGuide constraints on iOS 12 when built with iOS 14.1 SDK

风格不统一 提交于 2021-02-05 12:23:04
问题 I just wasted an hour with what looks like an iOS 14 SDK regression when running on iOS 12 so I thought i'd post this in case it helps others. Summary : When pinning the frame of the UIScrollView with the frameLayoutGuide as we've always done, this breaks on iOS 12 when the scrollview is contained within another view (in my case in a child viewcontroller, not sure if that matters). Setup : View setup, all views using autolayout: UIView "scrollviewContainerView" [fixed/unchanging size] | \-

UIScrollView ignores frameLayoutGuide constraints on iOS 12 when built with iOS 14.1 SDK

落爺英雄遲暮 提交于 2021-02-05 12:22:11
问题 I just wasted an hour with what looks like an iOS 14 SDK regression when running on iOS 12 so I thought i'd post this in case it helps others. Summary : When pinning the frame of the UIScrollView with the frameLayoutGuide as we've always done, this breaks on iOS 12 when the scrollview is contained within another view (in my case in a child viewcontroller, not sure if that matters). Setup : View setup, all views using autolayout: UIView "scrollviewContainerView" [fixed/unchanging size] | \-

How to move or resize an NSView by setting the frame property?

旧巷老猫 提交于 2021-01-29 20:42:05
问题 I created the NSView in a storyboard. In this case, it is an NSTextField . In the NSViewController 's viewDidLoad() method, I want to conditionally resize and reposition the NSTextField , but setting the frame has no effect. For example: class ViewController: NSViewController { @IBOutlet var label: NSTextField! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. label.frame = NSRect(x: 0, y: 0, width: 200, height: 17) label.setNeedsDisplay() }

How can I give constraints some margin from the center of superView

徘徊边缘 提交于 2021-01-29 19:30:52
问题 I am using auto layout. I have one UIView that takes place at 20px margin from the center of the superview. Right now I have given the Top Space to superview that i have make in the iPhone 6+ Xib. but when i run in the iPhone 4 simulator it goes to too much down. Any idea 回答1: If you want the view to be placed relative to the center of the superview, you should be using centerX and/or centerY constraints, not a constraint to the top of the superview. In IB, if you choose the "Vertical Center

UIScrollView with autolayout mixed approach?

…衆ロ難τιáo~ 提交于 2021-01-29 16:25:46
问题 I am trying to work an example code thats using the ' mixed approach ' mention on apple dev link: I am trying to stack 3 views vertically in UIScrollView. In below example the UIScrollView shows the red view on load but does not scroll as expected. I can scroll a little bit to see the green view below the red view - but the scroll view springs back up and does not scroll to the green view or view below it(blue view). I understand I need a constraint I tried to add one between view 1 & 2 so

UIView ignoring my constraints when setting width equal to scrollview?

喜你入骨 提交于 2021-01-29 07:54:32
问题 Every time I set the width of my view to my scroll view it pushes the green square off the screen. 回答1: @belgrim I had had a rough time working with scroll views. I would like to share my work around. First, drag a scroll view to your storyboard and pin in to four sides. Then, add a view inside the scroll view and pin it to the four sides of its superview (i.e. the scroll view) The result would look like this (Don't worry about the red markers, those will be fixes in the next steps) Add a

Detect when keyboard is fully visible and prevent keyboard appearance handling code from adding extra offset for hidden element

纵饮孤独 提交于 2021-01-29 05:41:02
问题 I want to know if the keyboard is fully visible and not if it's in in-between states of presentation. Unfortunately, all the answers use UIKeyboardDidShow , UIKeyboardWillShow , or UIKeyboardWillChangeFrame to check if keyboard is visible. All of these trigger listeners multiple times as the keyboard appears. So I can't use any of them to definitively tell if the keyboard is fully visible. I want to know if the keyboard is fully visible and prevent an action from triggering in my