uiview

Handling keyboard with bottom constraint

心不动则不痛 提交于 2021-01-28 08:06:08
问题 I'm building a chat app with a regular design and UI of a chat app. I have a "toolbar" that my app needs (0,0 375x66) and I want it to stay where it is when the keyboard is shown. It has 4 constraints: top: 0, leading: 0, trailing: 0, aspect-ratio: 125:22 I have a UICollectionView (0,66 375x530) that I want to be scrolled like any other chat app when the keyboard is shown. It has 4 constraints: top (to the toolbar): 0, leading: 0, trailing: 0, bottom (to the newMessageView I'll explain

How to get constraint “bottomSpace” from UIView Programmatically?

只愿长相守 提交于 2021-01-27 21:17:42
问题 I need change center of some views programmatically. 10 or more. I don't want to adding each bottom constraint as outlet, so could I search them from code like as: for(NSLayoutConstraint *constraint in view.constraints) Which attributes should I check? I need constraint for bottom space of superview. 回答1: Have you heard about IBOutletCollection ? When you link any object from IB to VC code, in popup window you can select IBOutletCollection Option. After link all constraints you want, only

UITapGestureRecognizer not working on custom UIView class

我的梦境 提交于 2021-01-27 18:43:15
问题 I've made a custom view class. I'm initializing it in my view controller class. I've enabled user interaction then also it's not working. I've searched it in similar questions but most of them say to enable user interaction. Here's the code I've written. @interface ProfileCreatorViewController (){ SectionTitleView *ProfileTitle; CGRect mainFrame; } @end @implementation ProfileCreatorViewController - (void)viewDidLoad { [super viewDidLoad]; mainFrame = CGRectMake(self.view.frame.origin.x, self

willMoveToWindow is called twice

柔情痞子 提交于 2021-01-27 06:28:27
问题 I'm swizzling willMoveToWindow: and I came across an issue where it was being called twice on views. When a new view controller is pushed onto a UINavigationController , willMoveToWindow: is called on the existing view with nil value (Makes sense since the view is moving offscreen) After that time, the method willMoveToWindow: is called again , but now with with the original window. My initial thought is that swizzling and calling the window property before the original method has kicked in.

willMoveToWindow is called twice

怎甘沉沦 提交于 2021-01-27 06:27:10
问题 I'm swizzling willMoveToWindow: and I came across an issue where it was being called twice on views. When a new view controller is pushed onto a UINavigationController , willMoveToWindow: is called on the existing view with nil value (Makes sense since the view is moving offscreen) After that time, the method willMoveToWindow: is called again , but now with with the original window. My initial thought is that swizzling and calling the window property before the original method has kicked in.

animate a UIView using CADisplayLink 'combined' with CAMediaTimingFunction. (to get a arbitrary curve)

ⅰ亾dé卋堺 提交于 2021-01-27 04:43:33
问题 I am using a CADisplayLink to do a view animation that just interpolates a value and redraws the view itself. e.g. I have a view MyView and it has a property value , whenever value is set I call setNeedsDisplay and the view knows what to draw. to animate this I use CADisplayLink and I want the view to 'morph' between values. I do this by just interpolating the value from the animation's start and stop Value: - (CGFloat)interpolatedValue:(CGFloat)sourceValue withValue:(CGFloat)targetValue

Swift - How to resize a UIView based on its UILabel size (that is inside)

流过昼夜 提交于 2020-12-06 02:59:28
问题 I'm a bit new in Swift, and I need some help with this: I have a UILabel inside a UIView, and this label can receive any ammount of text. So I want to resize the UILabel based on the text it receives, and also resizes its container, the UIView. The UILabel must have a max width but not max height. It is very similar to what happens in Whatsapp with a message text (his green container grows accordly the text inside). I believe it is about auto layout, but I really can't understand most of it.

Could not cast value of type UIView to [CustomView] using Xib

◇◆丶佛笑我妖孽 提交于 2020-11-29 10:14:15
问题 I've seen a number of similar questions, but many aren't up-to-date, and none have fixed my issue. I have a custom Xib and class, CardView . When I try to instantiate it in code, I get Could not cast value of type 'UIView' to 'CardView' . Class is as follows: class CardView: NibView { @IBOutlet var contentView: UIView! @IBOutlet weak var wordLabel: UILabel! @IBOutlet weak var flipButton: UIButton! @IBOutlet weak var playButton: UIButton! override init(frame: CGRect) { super.init(frame: frame)