I am creating a table view using AutoLayout for iOS 7 - iOS 9.
I have created a single cell prototype with .xib interface builder.
Inside the cell implementation I have no implementation yet.
Despite the fact, that AutoLayout constraints seems to be provided correctly, I am obtaining errors like this:
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x7fad5a80c3b0 UILabel:0x7fad585a6c60.width == UILabel:0x7fad5ad9f2b0.width>",
"<NSLayoutConstraint:0x7fad5a84c0a0 UILabel:0x7fad5ad9f2b0.leading == UILabel:0x7fad585a6c60.trailing + 10>",
"<NSLayoutConstraint:0x7fad5862a140 UILabel:0x7fad585a6c60.leading == MyCustomTableViewCell:0x7fad5ad88560.leading + 10>",
"<NSLayoutConstraint:0x7fad58621c30 MyCustomTableViewCell:0x7fad5ad88560.trailing == UILabel:0x7fad5ad9f2b0.trailing + 10>",
"<NSLayoutConstraint:0x7fad5ae218c0 MyCustomTableViewCell:0x7fad5ad88560.width == 1>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fad5a84c0a0 UILabel:0x7fad5ad9f2b0.leading == UILabel:0x7fad585a6c60.trailing + 10>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
When the breakpoint is reached, line [[[0x7fad5ad9f2b0 superview] superview] recursiveDescription] displays:
<VideoAnalysisVideoInformationTableViewCell: 0x7fad5ad88560; baseClass = UITableViewCell; frame = (0 301; 1 35); autoresize = W; layer = <CALayer: 0x7fad585445a0>>
| <UITableViewCellContentView: 0x7fad585d9d60; frame = (0 0; 1 35); opaque = NO; gestureRecognizers = <NSArray: 0x7fad585a2d30>; layer = <CALayer: 0x7fad585e9b40>>
| | <UILabel: 0x7fad585a6c60; frame = (10 5; 145 25); text = 'Score'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7fad5850b030>>
| | <UILabel: 0x7fad5ad9f2b0; frame = (165 5; 145 25); text = '33'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7fad5ad98210>>
| <_UITableViewCellSeparatorView: 0x7fad5a8cf620; frame = (15 34; 305 1); layer = <CALayer: 0x7fad5a9121d0>>
It seems, that the content view size is incorrect. How that could happen? How could I fix this?
You have set wrong constraints.
Give constraints like this,
Title label - leading and top
Info label - trailing and top
and select both label and give equal width. hope this will help :)
Update :
give top,leading,trailing and fix height to both label.
and give equal width
Related
only on iPhone 12 Pro Max iOS 14.4
When I click the back button on navigationBar
the touch event pass to the bottom collectionView cell
Any idea can fix this question?
Here is the hitTest on UIWindow's log when click back button
2021-06-30 15:55:27.724531+0800 FOURTRY[36793:4319245] hit test view ---- <UIButton: 0x7fee71054bb0; frame = (0 44; 44 44); opaque = NO; layer = <CAGradientLayer: 0x600003fb9400>>
2021-06-30 15:55:27.724987+0800 FOURTRY[36793:4319245] hit test view ---- <UIButton: 0x7fee71054bb0; frame = (0 44; 44 44); opaque = NO; layer = <CAGradientLayer: 0x600003fb9400>>
2021-06-30 15:55:27.725386+0800 FOURTRY[36793:4319245] hit test view ---- <UIView: 0x7fee6f72d140; frame = (0 0; 213.5 343.051); gestureRecognizers = <NSArray: 0x60000306f4e0>; layer = <CAGradientLayer: 0x600003fbd540>>
2021-06-30 15:55:27.725702+0800 FOURTRY[36793:4319245] hit test view ---- <UIView: 0x7fee6f72d140; frame = (0 0; 213.5 343.051); gestureRecognizers = <NSArray: 0x60000306f4e0>; layer = <CAGradientLayer: 0x600003fbd540>>
UIView: 0x7fee6f72d140 is the collectionView cell, Why happen this?
How is this possible?
(lldb) po contentView
<UITableViewCellContentView: 0x7fd0f3470c90; frame = (0 0; 400 699.5); opaque = NO; gestureRecognizers = <NSArray: 0x7fd0f346c980>; layer = <CALayer: 0x7fd0f3461930>>
(lldb) po UIScreen.mainScreen().bounds
origin=(x=0, y=0) size=(width=320, height=568)
Screen has 320px width but an empty custom table cell has 400.
Incase someone bumps into this, the culprit was the tableview. When I pinned it's edges to the superview, the cells started to work correctly.
I have created a UIScrollView in my Storyboards file, and properly connected it to my controller IBOutlet attribute. Here is what it looks like in Storyboards:
UIScrollView
UIView 1
UIView 2
UIView 3
Constraints
...
This is the code I am running on viewDidLoad:
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(#"COUNT: %d", [self.scrollView subviews].count);
for(UIView *v in [self.scrollView subviews]) {
NSLog(#"View: %#", v);
}
}
I was, therefore, expecting to see my 3 views listed in my console log. However, it is printing something totally unrelated (2 UIImageViews?):
2014-09-17 13:06:33.155 Project[6333:652705] COUNT: 2
2014-09-17 13:06:33.156 Project[6333:652705] View: <UIImageView: 0x7b094460; frame = (233 124.5; 7 3.5); alpha = 0; opaque = NO; autoresize = TM; userInteractionEnabled = NO; layer = <CALayer: 0x7b0947c0>>
2014-09-17 13:06:33.156 Project[6333:652705] View: <UIImageView: 0x7b094fb0; frame = (236.5 121; 3.5 7); alpha = 0; opaque = NO; autoresize = LM; userInteractionEnabled = NO; layer = <CALayer: 0x7b095080>>
I may be clearly doing something wrong here, but is there some sort of cache in Interface Builder or the Outlet connection itself?
The image views are the scrollers at the edge of the scroll view. When viewDidLoad is called the view hierarchy hasn't been fully installed yet. Move your code into the awakeFromNib method instead (and watch out for the image views - generally don't rely on the subviews, keep explicit references to the views you want to access).
I have used auto-layout and scrollview. I have created hierarchy in storyboard which looks as shown below :
Basically view has scrollview inside it and scrollview has another subview view1 inside it. Rest of the views are under view1.
While debugging one issue I am facing I show that self.scrollView.subviews prints 3 views. Out of them 2 are ImageViews. And those are not subview of scrollview as per the hierarchy in storyboard.
(lldb) po self.scrollView.subviews
<__NSArrayM 0xb66fe80>(
<UIView: 0xb74b110; frame = (0 0; 320 3240); autoresize = RM+BM; layer = <CALayer: 0xb74b170>>,
<UIImageView: 0xb7e61c0; frame = (313 476; 7 3); alpha = 0; opaque = NO; autoresize = TM; userInteractionEnabled = NO; layer = <CALayer: 0xb7e62a0>>,
<UIImageView: 0xb7e6350; frame = (314.5 3091.5; 3.5 36); alpha = 0; opaque = NO; autoresize = LM; userInteractionEnabled = NO; layer = <CALayer: 0xb7e6430>>
)
What can be wrong here? Ask for any detail you need.
The UIView on your console is this view
the 2 UIImageView's are the scroll indicators
And one cool thing to debug view hierarchy is recursiveDescription.
po [self.view recursiveDescription]
I'm having an issue with a view using autosizing resizing improperly in iOS7 (but fine in 6). The view initially renders as I'd expect, then I push another view onto the stack. Once I pop back to the original view, a subview that should be anchored on the right sizes itself too large and of the bounds of the superview.
It's a fairly simple view, created in a Storyboard, that includes the following hierarchy:
Scrollview -> View ->ImageView
It uses autosizing masks, which frankly was done because I had issues using autolayout inside the scrollview in this case (don't want to get into that here). The mask for the ImageView is pretty simple:
-
|
_
|-|<->|-|
-
|
-
On initial load, the X coord and width are as follows:
UIScrollView: frame = (0 64; 320 455); clipsToBounds = YES; autoresize
= W+H;
UIView: frame = (0 0; 320 568); autoresize = W+BM
UIImageView: frame = (20 110; 280 50); clipsToBounds = YES; opaque =
NO; autoresize = W;
On subsequent load, it appears as follows
UIScrollView: frame = (0 64; 320 455); clipsToBounds = YES; autoresize
= W+H
UIView: frame = (0 0; 320 568); autoresize = W+BM
UIImageView: frame = (20 160; 320 50); clipsToBounds = YES; opaque
= NO; autoresize = W
The notable difference being, as bolded, the width of the ImageView frame increases to 320, which is the size of it's bounds. Since it is still offset by 20, it ends up running off the screen. Obviously, I would expect it to stay at 280, as it does when this same thing is run in iOS6.
I don't manipulate the view in any way in code, so this should all be tied the autolayout masks. I cannot find anything about others having similar issues.
--