nslayoutconstraint

Wrong UITableViewCell height for some cells at first loading

↘锁芯ラ 提交于 2020-06-25 04:58:28
问题 I am using UITableViewAutomaticDimension to calculate height for my table view cell. It works fine for me. But for some cells, the height returned is 44 rather than dynamically calculating height. But on scrolling up an looking back to the same cell, the height is recalculated perfectly. So I guess I do not have any faulty constraints because, after I scroll and correct all cell heights manually, no constraint breaking warning are shown afterwards. Edit The below given is the screenshot of

Wrong UITableViewCell height for some cells at first loading

假装没事ソ 提交于 2020-06-25 04:58:08
问题 I am using UITableViewAutomaticDimension to calculate height for my table view cell. It works fine for me. But for some cells, the height returned is 44 rather than dynamically calculating height. But on scrolling up an looking back to the same cell, the height is recalculated perfectly. So I guess I do not have any faulty constraints because, after I scroll and correct all cell heights manually, no constraint breaking warning are shown afterwards. Edit The below given is the screenshot of

UIToolbar with UIBarButtonItem LayoutConstraint issue

怎甘沉沦 提交于 2020-06-10 12:52:29
问题 I'm creating a UIToolbar with UIBarButtonItem in it programatically. I'm not using .xib or storyboard for this ViewController. Here's the code of how I created it. NSMutableArray *items = [[NSMutableArray alloc] init]; UIBarButtonItem *buttonItem; buttonItem = [[UIBarButtonItem alloc ] initWithTitle: [Language get:@"Home" alter:nil] style: UIBarButtonItemStyleBordered target: self action: @selector(viewChangeTo)]; [items addObject:buttonItem]; toolbar = [[UIToolbar alloc] init]; toolbar.frame

iOS开发日记30-Autolayout

十年热恋 提交于 2020-03-15 09:15:18
今天博主有一个Autolayout的需求,遇到了一些困难点,在此和大家分享,希望能够共同进步. 1 、概述 在以前的 iOS 程序中,是如何设置布局 UI 界面的? (1)经常编写大量的坐标计算代码 (2)为了保证在3.5 inch和4.0 inch屏幕上都能有完美的UI界面效果,有时还需要分别为2种屏幕编写不同的坐标计算代码(即传说中的“屏幕适配”) 什么是 Autolayout ? (1)Autolayout是一种“自动布局”技术,专门用来布局UI界面的 (2)Autolayout自iOS 6开始引入,由于Xcode 4的不给力,当时并没有得到很大推广 (3)自iOS 7(Xcode 5)开始,Autolayout的开发效率得到很大的提升 (4)苹果官方也推荐开发者尽量使用Autolayout来布局UI界面 (5)Autolayout能很轻松地解决屏幕适配的问题 Autoresizing (1)在Autolayout之前,有Autoresizing可以作屏幕适配,但局限性较大,有些任务根本无法完成 (2)相比之下,Autolayout的功能比Autoresizing强大很多 Autolayout 的 2 个核心概念: (1)参照 (2)约束 2 、 Autolayout 的警告和错误 警告: 控件的frame不匹配所添加的约束, 比如: 约束控件的宽度为100,

Entering text into textfield causing uipangesture object to move back to its orginal position

谁说胖子不能爱 提交于 2020-03-04 19:40:10
问题 The bounty expires in 2 days . Answers to this question are eligible for a +50 reputation bounty. Mitch Mustain is looking for an answer from a reputable source : Just get a a uiimageview to move using uipangesutre and when text is enter into the textfield. The imageview does not return to its original position. My swift code below has a image view connected to a pangesture. When something is entered into a textfield when after the image view is moved. The image view reverts back to its

Draw custom separator line between UITableViewCell on iOS 7

一个人想着一个人 提交于 2020-02-06 08:41:00
问题 Because I had some troubles using the default separator line between the UITableViewCell I want to use my own. Therefore I'm using auto layout. C# is the language I used. You can of course provide solutions in Objective-C. In the constructor of my custom cell I add my view UIView : separator = new DividerView (); ContentView.Superview.AddSubview (separator); One has to add it to the superview otherwise it doesn't cover the accessory area. In updateConstraints I set up my constraints:

Draw custom separator line between UITableViewCell on iOS 7

纵饮孤独 提交于 2020-02-06 08:40:36
问题 Because I had some troubles using the default separator line between the UITableViewCell I want to use my own. Therefore I'm using auto layout. C# is the language I used. You can of course provide solutions in Objective-C. In the constructor of my custom cell I add my view UIView : separator = new DividerView (); ContentView.Superview.AddSubview (separator); One has to add it to the superview otherwise it doesn't cover the accessory area. In updateConstraints I set up my constraints:

is there is a way to create constraint greater than or equal relation through code

偶尔善良 提交于 2020-02-05 03:59:11
问题 I'm working on expandable table cell, and my algorithm is follow: I create two views. Create the height constraint of second view, drag it as IBOutlet to my cell. When cell is selected change status of selected cell. class ExpandableCell: UITableViewCell { @IBOutlet weak var expandableCellHeightConstraint: NSLayoutConstraint! @IBOutlet weak var expandableView: UIView! var isExpanded:Bool = false { didSet { if !isExpanded { self.expandableCellHeightConstraint.constant = 0.0 } else { self

How to align Custom cells to Right Detail and Basic cells?

落爺英雄遲暮 提交于 2020-01-17 03:35:32
问题 I am using static cells with 4 sections to create a Settings scene: For some cells I use the predefined styles: Right Detail and Basic . But for the following cells I use Custom style with my own constraints: Label on the left and Switch on the right side (like the cell selected in above screenshot) Slider occupying the whole cell My problems: I can not get the leading alignment right and also my 2-lines word-wrapping Label pushes a Switch to the right: As you can see at the top screenshot,

weird positioning of the cursor in the UITextView

不羁岁月 提交于 2020-01-14 09:22:07
问题 I am writing from scratch growing UITextView in my swift app. I put a textView on the view like this: it is right above the keyboard. The textView has constraints attached to the view : leading , bottom , top and trailing , all equals = 4 . The view has the following constraints: trailing , leading , bottom , top and height Height is an outlet in my code. I'm checking how many lines are in the textView and based on that I'm modifying height : func textViewDidChange(textView: UITextView) { /