ios-autolayout

Landscape view issue with navigation bar

余生颓废 提交于 2019-12-11 03:27:02
问题 Default Navigation bar height is 64.But after change it's orientation to landscape navigation bar height changed to 28.I want to set Fix navigation bar size in all orientation. 回答1: You can add orientation observer: NotificationCenter.default.addObserver(self, selector: #selector(rotated), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil) And add rotate method: func rotated() { let height: CGFloat = 50 //whatever height you want to add to the existing height let bounds =

Getting ScrollView to Work with Autolayout and Storyboard

故事扮演 提交于 2019-12-10 20:28:49
问题 I am trying to make a really simple layout for an app I want to build - but I seem to be struggling with ScrollView and getting it to work via Storyboard. Basically I am trying to build below: I have done the constraints using several tutorials - but it either doesn't scroll or it looks wrong. Any suggestions? I am getting the following warning: 回答1: You have to provide the contentSize for a UIScrollView when laying it out using constraints. For example: You can set the width of View to be

AutoLayout: UIImageView and Aspect Fit content mode

ぐ巨炮叔叔 提交于 2019-12-10 18:00:53
问题 I'm trying to place an UIImageView in the parent view's center. Image must keep its original aspect ratio and also it shouldn't exceed parent's bounds. So landscape images should be limited by parent's width and portrait images should occupy as much vertical space as needed keeping original ratio. Sounds like quite a simple task for AutoLayout, right? Here's my setup for UIImageView : center vertically in parent center horizontally in parent imageView.width <= superview.width imageView.height

Why do we need invalidateLayout?

偶尔善良 提交于 2019-12-10 15:27:27
问题 i tried to implement rotation adjustments so in tutorial author was using invalidatelayout function before setting new preferences. but all actually works without invalidateLayout, and yet i tried it in another circumstance before and got the same "nothing" output. override func willTransition(to newCollection: UITraitCollection, with coordinator: UIViewControllerTransitionCoordinator) { collectionView.collectionViewLayout.invalidateLayout() let indexPath = IndexPath(item: pageControl

iOS App layout is wrong with calling status bar

懵懂的女人 提交于 2019-12-09 18:38:50
问题 Faced with an issue with status bar during active call and application layout. I'm using autolayouts. When I run the app, and then start a call, all works fine, the UI is scaled properly with changed status bar. But if I first start a call and then run the app, application screens moved for 20pt to the bottom, like if they did not react on new status bar. And even if I will turn off the call, the UI will be moved to bottom. Maybe somebody know how o fix that? 回答1: This is easy, when you gave

Setting auto layout constraints programmatically on two views in ViewController

我是研究僧i 提交于 2019-12-08 02:16:56
问题 I am trying to add two UIView on ViewController. One of them is plain UIView and other is UITableView. I am not quite sure how to set height constraint on them in such away that UITableView will be of height required for its content and other view can resize itself based on UITableView height. Below is the simple sketch and code I am using for setting up those constraints. NSDictionary *views = NSDictionaryOfVariableBindings(_infoView,_infoTableView); [self.view addConstraints:

UITableView with self sizing cells becomes jerky when calling deleteRowsAtIndexPaths

别说谁变了你拦得住时间么 提交于 2019-12-07 20:03:07
问题 I have a UITableView with self sizing cells. Table contains 1 section and some rows. I have some rows say 30 and I want to delete row during didSelectRowAtIndexPath . When I delete a row available near the bottom of tableview (say 28th row ), the rows before 28th row changes their position and it causes jerky animation as a result of deleteRowsAtIndexPaths . See attached gifs for more details. Cells constructed with frame deletion animation Auto Resizing cells Deletion animation - (NSInteger

How to add Constraint programmatically in objective c

血红的双手。 提交于 2019-12-07 06:09:13
问题 I want to add constraint programmatically and I use below code to add TOP and LEFT constraint. NSLayoutConstraint *top = [NSLayoutConstraint constraintWithItem:label1 attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1 constant:110]; NSLayoutConstraint *left = [NSLayoutConstraint constraintWithItem:label1 attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeading

Personal Hotspot breaks UI layout

孤人 提交于 2019-12-06 15:01:48
问题 When the personal Hotspot is activated and bar resizes itself to 40px, the view does not resize correctly. The bottom goes 20px below the screen instead of being resized. I am using Auto Layout in all my View Controllers but even though my app UI breaks like the image shows below. Any help would be great.! 回答1: Register this notification in your viewdidload - (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector

UITableView with self sizing cells becomes jerky when calling deleteRowsAtIndexPaths

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 11:05:00
I have a UITableView with self sizing cells. Table contains 1 section and some rows. I have some rows say 30 and I want to delete row during didSelectRowAtIndexPath . When I delete a row available near the bottom of tableview (say 28th row ), the rows before 28th row changes their position and it causes jerky animation as a result of deleteRowsAtIndexPaths . See attached gifs for more details. Cells constructed with frame deletion animation Auto Resizing cells Deletion animation - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } -(CGFloat)tableView:(UITableView *