nsautolayout

Complex AutoLayout for Cell with dynamic size

﹥>﹥吖頭↗ 提交于 2019-12-08 09:54:24
问题 I have a cell that contains a container with 10 subviews (two of them are simply bounds and the others are labels). The scheme looks like this. Dynamic labels may contain huge text so the cells should conform the appropriate size to fit the content. The question is how to set up all the constraints manually... I've tried a dozen of times to do it myself but seems I'm not that good at this. The table view supports auto dimension for row height and uses custom estimated height. In Storyboard it

Autolayout programmatically doesn't work

拥有回忆 提交于 2019-12-04 04:02:08
问题 I want to add programmatically an UIImageView to a view and add constraints to center it, vertically and horizontally. With the storyboard it's works but not programmatically. class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() var transitionImageView = UIImageView() transitionImageView.frame.size = CGSize(width: 60, height: 68) transitionImageView.contentMode = UIViewContentMode.ScaleToFill var transitionImage = UIImage(named: "SoProxyLogo60pt")

Strange exception in layouts

北城以北 提交于 2019-12-02 23:17:12
Try call this method: avatarIconImageView.setContentHuggingPriority(UILayoutPriorityDefaultLow, forAxis: UILayoutConstraintAxis.Horizontal) and catch this exception: Undefined symbols for architecture armv7: "_UILayoutPriorityDefaultLow", referenced from: __TFC13TCProject_iOS36TCAvatarWithCounterUniversalCellView22configureBodyCellViewsfS0_FT_T_ in TCAvatarUniversalCellView.o ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation) what it means? This looks like a bug in the iOS 8 SDK. You can work around this by just

Multi-line NSTextField not working

浪尽此生 提交于 2019-12-02 00:03:00
问题 I have been trying to get a multi-line NSTextField to lay out automatically using preferredMaxLayoutWidth . I can’t figure out why this doesn’t work. class ViewController: NSViewController { override func viewDidLoad() { super.viewDidLoad() let textField = NSTextField() textField.cell!.usesSingleLineMode = false textField.cell!.wraps = true textField.cell!.lineBreakMode = .byCharWrapping view.addSubview(textField) textField.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint

Autolayout programmatically doesn't work

混江龙づ霸主 提交于 2019-12-01 20:25:22
I want to add programmatically an UIImageView to a view and add constraints to center it, vertically and horizontally. With the storyboard it's works but not programmatically. class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() var transitionImageView = UIImageView() transitionImageView.frame.size = CGSize(width: 60, height: 68) transitionImageView.contentMode = UIViewContentMode.ScaleToFill var transitionImage = UIImage(named: "SoProxyLogo60pt") transitionImageView.image = transitionImage self.view.addSubview(transitionImageView) // Position let

IOS AutoLayout Change position on Rotation

笑着哭i 提交于 2019-12-01 09:52:25
问题 I wanted to sent one container below the other on portrait and side by side on landscape. Is it possible with just auto layout? I know i can do it programmatically, just wondering if it is possible to do it from the layout. Like This: 回答1: Well didRotateFromInterfaceOrientation is not the preferred way to do these kind of things with iOS 8. I would suggest you to take a look at traitCollection and view controller methods associated with it. The trick here is to install horizontal constraint

AutoLayout, Unable to simultaneously satisfy constraints

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 17:20:59
Just started learning iOS AutoLayout, Interface builder very straight forward, but when I try to archive the same thing on the code [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-(==2)-[_nextKeyboardButton]-(==2)-[_numPadButton]-(==2)-[_spaceButton]-(==2)-[_returnButton]-(==2)-|" options:0 metrics:0 views:NSDictionaryOfVariableBindings(_nextKeyboardButton,_numPadButton,_spaceButton,_returnButton)]]; it raises an exception, Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this

AutoLayout, Unable to simultaneously satisfy constraints

拟墨画扇 提交于 2019-11-26 18:57:02
问题 Just started learning iOS AutoLayout, Interface builder very straight forward, but when I try to archive the same thing on the code [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-(==2)-[_nextKeyboardButton]-(==2)-[_numPadButton]-(==2)-[_spaceButton]-(==2)-[_returnButton]-(==2)-|" options:0 metrics:0 views:NSDictionaryOfVariableBindings(_nextKeyboardButton,_numPadButton,_spaceButton,_returnButton)]]; it raises an exception, Unable to simultaneously satisfy

Using Auto Layout in UITableView for dynamic cell layouts & variable row heights

穿精又带淫゛_ 提交于 2019-11-25 23:55:48
问题 How do you use Auto Layout within UITableViewCell s in a table view to let each cell\'s content and subviews determine the row height (itself/automatically), while maintaining smooth scrolling performance? 回答1: TL;DR: Don't like reading? Jump straight to the sample projects on GitHub: iOS 8 Sample Project - Requires iOS 8 iOS 7 Sample Project - Works on iOS 7+ Conceptual Description The first 2 steps below are applicable regardless of which iOS versions you are developing for. 1. Set Up & Add