Comments (4)
This works. However, you cannot use UITableViewAutomaticDimension
with the above. For example, if you constrained [shimmerView.heightAnchor constraintGreaterThanOrEqualToConstant:50.0].active = YES
and made the UITableView height dynamic, you will get more constraint problems. However if you did the same to bottomView
, it will work just fine.
I will be using a static height anyway so it doesn't matter, but I just thought I'd mention it in case someone came along with the same issue.
from shimmer.
You don't need to constrain the size of the content view: it is automatically sized to match the shimmer view, through the lines of code you showed above.
Does it work without that constraint?
from shimmer.
No it doesn't work without that constraint. Instead it doesn't display at all.
With FBShimmeringView: http://imgur.com/50W0YOc
Without FBShimmeringView: http://imgur.com/v2hB2Qw
I created a sample test project to show the issue: https://github.com/Brandon-T/FBShimmerTest/tree/master/FacebookShimmerTest
In the LoadingCell
class I added a macro #define kDisableFBShimmering
. If it is defined, then you can see everything works perfectly. The views get displayed. Console does not log any errors.
However, when I comment it out (enable FBShimmering), you can see the console spitting out a lot of errors and nothing gets disabled on screen.
from shimmer.
I took a look in the Xcode view debugger, and it looked like the bottom view is positioned and sized correctly. The issue is the subviews of the bottom view. I remembered that autolayout requires geometry methods to be called on UIView
, rather than CALayer
, as Shimmer is currently implemented.
Changing that makes the views appear, but there's still log messages about unsatisfied constraints. Investigating those, it appears the issue is that your constraints setup in BottomView
require a certain minimum width and height of the BottomView
to resolve. In a pure-autolayout world, that's OK, because that requirement is factored into constraint resolution. But Shimmer's manual sizing of the BottomView
happens after the autolayout pass, so the BottomView
needs a sufficient initial size.
In summary, the two fixes to make this work:
-
In your
LoadingCell.m
, right after creating aBottomView
, give it an initial size. Note that the size is arbitrary, as long as it's as big asBottomView
's layout requires, and that this can't use-initWithFrame:
becauseBottomView
overrides the convenience initializer-init
instead.self.bottomView.frame = CGRectMake(0, 0, 500, 1000);
Alternatively, you could add the constraints in
BottomView
later, after initialization, when the view has a correct size. -
In Shimmer's
FBShimmeringView.m
, add this method to set the frame of the view instead of the layer:- (void)layoutSubviews { // Autolayout requires these to be set on the UIView, not the CALayer. // Do this *before* the layer has a chance to set the properties, as the // setters would be ignored (even for autolayout) if set to the same value. _contentView.bounds = self.bounds; _contentView.center = self.center; [super layoutSubviews]; }
This is pushed to master as 3589bd7.
from shimmer.
Related Issues (20)
- Updates please! HOT 1
- shimmer diagonal animation
- updating the pod to Swift4.0 version
- What happened with this repo? HOT 5
- Unable to add Shimmer Framework manually in custom swift Framework
- Carthage support for Shimmer HOT 1
- Is there any user data that is either being collected or Tracked by the Shimmer
- .
- Assigning to 'id<CALayerDelegate> _Nullable' from incompatible type 'FBShimmeringLayer *const __strong'
- Facebook>Chat panel HOT 1
- Missing Android Support HOT 1
- SIGSEGV when deallocating view controller HOT 1
- Tag a new release ? HOT 2
- Issues when used with views inside of UIStackView HOT 1
- Shimmer crashes EarlGrey
- Xcode 8.3 warning HOT 3
- Mask angle/tilt HOT 2
- Please update the CocoaPod!
- please show an example of using this in swift 3 or 4. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shimmer.