autolayout

How would I get reference to my custom collection view cell inside the method that declares the GCSize?

浪子不回头ぞ 提交于 2020-01-06 02:49:05
问题 I have a collection view with custom view cells.. I am trying to get the reference of the cell where it's defining the height: - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { CGRect screenBound = [[UIScreen mainScreen] bounds]; CGSize screenSize = screenBound.size; CGFloat screenWidth = screenSize.width; MyCustomCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier

Auto Layout center UIView above another UIView at its center

孤街浪徒 提交于 2020-01-06 01:32:12
问题 I have a UIView ( popup ) and multiple UIButton s ( sender ). If I touch the sender I would like to center the popup at the coordinates of the sender . However, as of Auto Layout the popup always moves back to the initial position at refresh. I understand that I have to use constraints and change those programmatically. Unfortunately I don't know how I can adjust below code with constraints. Especially as the popup is larger as the sender . Could anybody give me some advice on how to move

iOS: Auto Layout: Two buttons side-by-side when there's enough space, otherwise on top of one another

走远了吗. 提交于 2020-01-05 11:05:39
问题 Looking for an auto layout solution where two buttons lie side-by-side when there is enough space to do so, but otherwise (when the view is displayed with limited width) rest on top of one another. I don't even know where to begin to think this through with auto layout. Any help is appreciated! 回答1: I'd imagine this being a combo between autolayout and an NSLayoutConstraint property constant, whereby you set the constraints in IB/Storyboard, and click-drag the trailing space to container

iOS: Auto Layout: Two buttons side-by-side when there's enough space, otherwise on top of one another

北战南征 提交于 2020-01-05 11:03:11
问题 Looking for an auto layout solution where two buttons lie side-by-side when there is enough space to do so, but otherwise (when the view is displayed with limited width) rest on top of one another. I don't even know where to begin to think this through with auto layout. Any help is appreciated! 回答1: I'd imagine this being a combo between autolayout and an NSLayoutConstraint property constant, whereby you set the constraints in IB/Storyboard, and click-drag the trailing space to container

Correct subclassing and autolayout of UITableViewHeaderFooterView

丶灬走出姿态 提交于 2020-01-05 08:42:59
问题 Here's how I set stuff up in my UITableViewHeaderFooterView view. - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self.contentView addSubview:self.createHeader]; } return self; } - (UIView *)createHeader { UIView *headerContainer = [[UIView alloc] init]; headerContainer.backgroundColor = [UIColor blackColor]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero]; label.translatesAutoresizingMaskIntoConstraints = NO; label.text = @"titlename";

Correct subclassing and autolayout of UITableViewHeaderFooterView

亡梦爱人 提交于 2020-01-05 08:42:31
问题 Here's how I set stuff up in my UITableViewHeaderFooterView view. - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self.contentView addSubview:self.createHeader]; } return self; } - (UIView *)createHeader { UIView *headerContainer = [[UIView alloc] init]; headerContainer.backgroundColor = [UIColor blackColor]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero]; label.translatesAutoresizingMaskIntoConstraints = NO; label.text = @"titlename";

How to equally distribute UIButtons using Autolayout

纵然是瞬间 提交于 2020-01-05 07:51:11
问题 I just want my buttons to have equal spaces to each other and a fixed trailing and leading space. I am kinda Autolayout noob, so I don't have any clue how to solve this problem. I tried a lot of different configurations but nothing worked as it should. Any ideas how to solve this Issue ? UPDATE In year 2018 StackViews are the answer. 回答1: To lay out several views that are proportionally spaced based on the orientation of a device, create spacer views between the visible views. Set the

Autolayout in UIView where is safe to ask computed layout values?

不想你离开。 提交于 2020-01-05 07:48:51
问题 I've got this issue. I'm using a collection view as a subview of the main view of a UIViewController . The collection view is pinned to the superview size, thus it has 4 constraints for lead,trail, top and bottom with constants equal to 0. The cell is a subclass to UICollectionViewCell and is composed by: first header view second header view UITableView The collection view cell is loaded from xib and the interface of the views is made for 4 inches devices. The first header view is pinned at

How to place N number of views Horizontally in scrollview using auto layout programmatically?

时光总嘲笑我的痴心妄想 提交于 2020-01-05 07:13:46
问题 I want to create N number of views in horizontally in scrollview . so I have created One Temporary View and i assigned current view to that.Then i place constraints based on that.Only one view showing others not showing. I want Horizontal space between two views. I am using VFL to set a auto layout. Here is my trying code. func ect() { let scrollHeight = self.scrollObj.frame.size.height - 40 let scrollHeightString = String(describing: scrollHeight) print(scrollHeightString) var firstTextView

Autolayout with UIScrollView

你。 提交于 2020-01-05 05:53:34
问题 I am using autolayout in Xcode and am creating a fairly tall (1300px) ViewController with a uiscrollview to navigate up and down. I made the viewcontroller freeform so its dimensions are [375,1300]. I then incorporated the scrollview, added the content view as well as all the subviews & constrained everything, leaving no constraint errors. At runtime there are no errors, but everything is all smushed into the normal screen size when I intended for it to be very tall (~1300px) and scrollable.