autolayout

AutoLayout Stack View 实践笔记

大憨熊 提交于 2020-02-01 03:47:50
水平方向,五个按钮为一组,设置属性如下:Alignment: Fill, Distribution: Fill Equally, Spacing: 1 将 Label 和第1步中的所有5个水平 Stack view 放入一个垂直 Stack view 中-堆栈属性为:Alignment: Fill, Distribution: Fill Equally, Spacing: 1 垂直 Stack view 固定到父视图的四个边缘 将步骤3中设置的约束更改为相对于 Safe Area 而不是 superview 。 如果您希望 label 在左右两侧都有填充,则需要将其嵌入到 View 中,然后将 label 的两边约束设置为20px,顶部设置 2px,底部设置 0px 。 如果您希望0按钮和 . 按钮、=按钮占用一样大的空间,则需要将 . 按钮、=按钮嵌入到一个 stack view中。两个水平 Stack view 均将“ Distribution”设置为“Fill Equally”。 源码下载: https://github.com/iJoeychang/Calculator-Layout-iOS13-Completed 本文由博客一文多发平台 OpenWrite 发布! 来源: CSDN 作者: 跃然 链接: https://blog.csdn.net/changyou0730

Universal layout vs different iphone/ipad storyboards

随声附和 提交于 2020-01-31 03:42:04
问题 Is it okay to use different storyboards for different screensizes? I just can't make my png and icons images work for one storyboard as universal, it's a pain! What about universal iPhone and universal for iPad? What's the best way? Thanks 回答1: You can also use one storyboard and set layout and font according to your requirements. 1) To set up layout properly for both iPhone and iPad, you need to use Aspect Ratio. You can check the answer in detail following these two links: 1) What

Swift UITableViewAutomaticDimension not working

早过忘川 提交于 2020-01-26 02:32:03
问题 I am trying to get auto re-sizing of my table cells working. I have simplified my cells so that I just have a single label. When running my code in the simulator on a 4s it works fine, but when running on a real 4s device I get a strange gray square over most of the table, and lots of logging with messages like: Will attempt to recover by breaking constraint My understanding of constraints still isnt great, but I have setup a top, bottom, leading and trailing margin on my label. I have the

Swift UITableViewAutomaticDimension not working

空扰寡人 提交于 2020-01-26 02:30:16
问题 I am trying to get auto re-sizing of my table cells working. I have simplified my cells so that I just have a single label. When running my code in the simulator on a 4s it works fine, but when running on a real 4s device I get a strange gray square over most of the table, and lots of logging with messages like: Will attempt to recover by breaking constraint My understanding of constraints still isnt great, but I have setup a top, bottom, leading and trailing margin on my label. I have the

Constraints to be set for x position

限于喜欢 提交于 2020-01-25 04:01:27
问题 I've a scenario where in I've to display four circles. These should be in center of screen. I tried to place x and top constraint but this doesn't works fine for iPhone 4 device. What constraints should I set so that all four circles should appear in center for all iPhone device? Further, there is UICollectionView in bottom. I tried to set the top, left, w and height but this didn't worked. Any solution? 回答1: 1) Embed your 4 circle in UIView. 2) Set UIView constraint top, fixed width,fixed

Increase height of tableview cell according to amount of UILabel text

限于喜欢 提交于 2020-01-24 12:34:32
问题 I want to change the height of my tableview cell according to the amount of text by using auto layout. I have tried the following code but it doesn't work: - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { AddTaskDetails *addTaskDetail = (self.tasksArray)[indexPath.row]; CGFloat height; float textcount = [addTaskDetail.taskDetail length]; if(textcount>60) { height = textcount-20; NSLog(@"%d,%f",indexPath.row,height); } else { height = 70; }

Increase height of tableview cell according to amount of UILabel text

狂风中的少年 提交于 2020-01-24 12:32:48
问题 I want to change the height of my tableview cell according to the amount of text by using auto layout. I have tried the following code but it doesn't work: - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { AddTaskDetails *addTaskDetail = (self.tasksArray)[indexPath.row]; CGFloat height; float textcount = [addTaskDetail.taskDetail length]; if(textcount>60) { height = textcount-20; NSLog(@"%d,%f",indexPath.row,height); } else { height = 70; }

Anchor Constraints not Honored in Xcode 10 / iOS 12

∥☆過路亽.° 提交于 2020-01-24 12:18:06
问题 This all worked yesterday under Xcode 9 and iOS 11; however, after updating to Xcode 10 and iOS 12, the view is no longer showing. I was having a video displayed inside a view. Today I could hear but not see the video. I checked the frame and found it to be zero which explained the issue. However, nothing had changed from the prior version. I have removed the video stuff and have just looked at the view's frame after anchor constraints were applied and they are all zero. import UIKit import

Nested UITableView dynamic height

ぐ巨炮叔叔 提交于 2020-01-24 10:36:28
问题 I need to have a nested UITableView in a tableView cell (actually, two tables in one cell) to show different lists with dynamic content (so, I need dynamic heights). My nested tables will not have scrolling—I need them just to order elements of different kinds, like texts, pictures, fields etc. To be more clear—the first level is the level of operations and every operation can have a variable amount of instructions and actions. Instructions and actions should be placed side by side and the

屏幕适配

心不动则不痛 提交于 2020-01-23 06:23:44
适配 什么是适配? 适应、兼容各种不同的情况 移动开发中,适配的常见种类 系统适配 针对不同版本的操作系统进行适配 屏幕适配 针对不同大小的屏幕尺寸进行适配 屏幕适配 iPhone的尺寸 3.5inch、4.0inch、4.7inch、5.5inch iPad的尺寸 7.9inch、9.7inch、12.9inch 屏幕方向 竖屏 横屏 点和像素 在用户眼中 屏幕是由无数个像素组成的 像素越多,屏幕越清晰 在开发者眼中 屏幕是由无数个点组成的,点又是由像素组成的 像素越多,屏幕越清晰 设备分辨率 简介(屏幕适配发展史) 在以前的iOS程序中,是如何布局UI界面的? 写固定值-> autoresizingMask -> autolayout-> sizeClasses iPhone1-iPhone4s时代 屏幕的尺寸固定为(320,480) ,我们只需要简单计算一下相对位置就好了 iphone5-iphone5s时代屏幕的尺寸变了(320,568) 这时AutoresizingMask派上了用场(为什么不用Autolayout? 因为还要支持ios5) iphone6时代 屏幕的宽度也发生了变化,终于是时候抛弃AutoresizingMask改用Autolayout了(1.不用支持ios5了 2. 相对于屏幕适配的多样性来说autoresizingMask也已经过时了)