Comments (9)
The reason you're running into a crash is because setting rcl_frame
generates a value on rcl_frameSignal
, leading to an infinite loop.
What is that code actually intended to do? It's generally a bad idea to create a feedback signal like this.
from reactivecocoalayout.
I just want to horizontally center self.playButton and set its y coordinate to 0. (so it's top is aligned to its superview top)
from reactivecocoalayout.
In that case, I would observe rcl_boundsSignal
or rcl_intrinsicContentSizeSignal
. You don't actually care about the frame, since the origin is completely discarded, and only the size remains.
from reactivecocoalayout.
Ok, I think I understand better. Does this also create an infinite loop?
RAC(myButton,rcl_bounds) = [myButton.rcl_boundsSignal
replaceWidth:myButton.superview.rcl_boundsSignal.width];
If so, what's the best way to set the bounds or frame relative to its current value? That's what I'm trying to do here. Do I need to create a whole new rect signal when use RAC/RCL to set bounds/frame?
from reactivecocoalayout.
If so, what's the best way to set the bounds or frame relative to its current value? That's what I'm trying to do here.
Since signals operate over time, it doesn't really make sense to do that. What's your end goal?
from reactivecocoalayout.
I just want to position and size my UIView's. Nothing abnormal. The reason I've used the above code is to avoid doing something more verbose like this everytime:
RAC(myButton,rcl_bounds) = [RACSignal rectsWithX:[RACSignal return:@20]
Y:myButton.superview.rcl_boundsSignal.y width:[RACSignal return:@40]
height:myButton.superview.rcl_boundsSignal.height];
Is this the recommended approach?
See how constructing a new rect signal is more verbose than just getting the current bounds rect and adjusting one property (like width using replaceWidth
)? I guess my what I've been doing is wrong so I'm gonna go back and look at the demos some more.
I know you're busy so I'm gonna close this (I won't keep responding). Your answers are VERY HELPFUL so thank you. If you get a chance, just let me know if the rectsWithX:
approach is a bit more on the right trail. Or point me to the relevant line in one of the demos.
from reactivecocoalayout.
Constructing a new rect is indeed the recommended way to do it. RCL favors creating layouts from scratch, rather than trying to modify the existing properties of a view, because signal feedback is very tricky to handle correctly.
If you really want to base your layout on the current bounds rectangle, that's possible. You just don't want it to update when it changes in the future. Create a signal from the current value βΒ don't observe the property:
RAC(myButton,rcl_bounds) = [[RACSignal
return:MEDBox(myButton.bounds)]
replaceWidth:myButton.superview.rcl_boundsSignal.width];
from reactivecocoalayout.
Perfect, thank you again.
from reactivecocoalayout.
No problem!
from reactivecocoalayout.
Related Issues (20)
- when I set rcl_top , why the height and width changed ? HOT 1
- Add Carthage compatibility badge to the README
- Split animation behaviors into a separate library HOT 3
- Concat after animation HOT 1
- -rcl_frameSignal etc al should complete on object dealloc HOT 1
- NSView.rcl_baselineSignal does not update
- ld: library not found for -lReactiveCocoaLayout iOS HOT 1
- Add bootstrap and cibuild scripts
- Where is rcl_center? HOT 4
- Why can't I do both alignTop and alignRight? HOT 2
- ResizingWindow demo has a lot of layer-backing artifacts HOT 1
- ResizingWindow throws exceptions if the window is sized too small
- A signal equivalent to AVMakeRectWithAspectRatioInsideRect ? HOT 6
- (NS | UI)EdgeInsets operators HOT 6
- Equally Space Views HOT 2
- CGRectInset() returning NaN values HOT 9
- Adopt the Flexbox spec. It's been much improved over the past year. HOT 2
- Create New Tag HOT 3
- RCL doesn't respect `flipped` coordinate space? HOT 2
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 reactivecocoalayout.