autolayout

Dynamic UIImageView Size Within UITableView

删除回忆录丶 提交于 2019-12-17 21:52:34
问题 I want to implement a TableView with a Custom TableViewCell showing an image. To make this simple, I simply put a UIImageView inside a tableviewcell using autolayout (illustrated below). What I want is to display the image inside a UIImageView however those images dimensions can be anything and are inconsistent (portrait, landscape, square) ... Therefore, I'm looking to display an image with a fixed width (the width of the device) and a dynamic height that respect the ratio of the images. I

Autolayout - intrinsic size of UIButton does not include title insets

好久不见. 提交于 2019-12-17 21:37:55
问题 If I have a UIButton arranged using autolayout, its size adjusts nicely to fit its content. If I set an image as button.image , the instrinsic size again seems to account for this. However, if I tweak the titleEdgeInsets of the button, the layout does not account for this and instead truncates the button title. How can I ensure that the intrinsic width of the button accounts for the inset? Edit: I am using the following: [self.backButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 5, 0, 0)]; The

Xamarin iOS: Auto Layout within scroll view?

白昼怎懂夜的黑 提交于 2019-12-17 21:35:49
问题 I have a scrollView on my storyboard on which I have added top, left, right, bottom constraints in order for it to resize automatically in accordance with different screen sizes. The problem is that if I add image view or any other stuff within this scroll view and place constraints on this image view to maintain some distance from top, left, right and bottom of the scrollview boundaries. It just doesn't work. I Would like to have everything resized according to the screen size of the target

iOS - Custom table cell not full width of UITableView

ぐ巨炮叔叔 提交于 2019-12-17 19:49:47
问题 I may be going about this wrong. So I have created a UITableView that essentially has a auto-layout trailing space set to the main view. I am creating a custom cell for this table so I drug on a prototype cell, customized it, and created my class for it. That is all working just fine. What I can't seem to solve is the custom cell isn't going the full width of the actual table cell so a white background just shows up. If I don't use the custom cell the entire width table cell gets utilized. I

How to load multiple storyboard files depending on iOS version? (5 and 6)

六月ゝ 毕业季﹏ 提交于 2019-12-17 18:58:43
问题 I have a tab bar controller app that I am trying to make compatible for iOS 6 and iOS 5. For iOS 6, I use auto layout. But when trying to run on iOS 5, I get an error due to it not recognizing NSLayoutConstraints. From what I can tell, I am required to use a different storyboard without auto layout enabled. I have copied my storyboard into a new one, but don't know how to set which storyboard to use in the app delegate. Whats the code to do this? 回答1: In your app delegate, you should find

UILabel Text Not Wrapping

匆匆过客 提交于 2019-12-17 18:13:20
问题 I am working on a Swift project with Storyboards where I want text to wrap in a label. In the old Objective-C version where I did not use a Storyboard I used the following settings and things worked perfectly. Here are the settings for Swift I have been reading about the potential auto layout issues with preferred width settings. I currently have them set to auto layout and the label itself is set to a width of 560. I've added a constraint to keep the label 20 pixels from the trailing

iOS - Position UIView in center of superview using Auto Layout programmatically

旧时模样 提交于 2019-12-17 17:46:25
问题 How do you programmatically set a UIView to be in the center of its superview using Auto Layout? UIButton* viewObj = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [viewObj setTranslatesAutoresizingMaskIntoConstraints:NO]; [viewObj setBackgroundColor:[UIColor greenColor]]; [self.view addSubview:viewObj]; NSLayoutConstraint* cn = [NSLayoutConstraint constraintWithItem:viewObj attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.view attribute

Programmatic UIScrollview with Autolayout

笑着哭i 提交于 2019-12-17 17:34:57
问题 After reading the technical notes on apple's website and reading matt neuburg's book on programming iOS 11 with a UIScrollview held in place with Autolayout, I have not been able to fully understand the concept of how it all works. Basically what I want to have is a Scrollview that would have a child view ChildView where this child view then has a Textview . Below I have attached the mockup of what I am trying to achieve Programmatically no-nibs, no storyboards. and as for the code, This is

activateConstraints: and deactivateConstraints: not persisting after rotation for constraints created in IB

拥有回忆 提交于 2019-12-17 15:53:56
问题 The new NSLayoutConstraint methods activateConstraints: and deactivateConstraints: don't appear to work correctly with IB-created constraints (they do work correctly for code-created constraints). I created a simple test app with one button that has two sets of constraints. One set, which is installed, has centerX and centerY constraints, and the other set, which is uninstalled, has top and left constraints (constant 10). The button method switches these constraints sets. Here is the code,

Setting tableHeaderView height dynamically

允我心安 提交于 2019-12-17 15:44:16
问题 My application creates a UITableViewController that contains a custom tableHeaderView which may have an arbitrary height. I've been struggling with a way to set this header dynamically, as it seems the suggested ways have been cutting this header short. My UITableViewController's relevant code: import UIKit import SafariServices class RedditPostViewController: UITableViewController, NetworkCommunication, SubViewLaunchLinkManager { //MARK: UITableViewDataSource var post: PostData? var tree: