近期RAC中给scrollview添加观察者,接收滑动的数值时发现返回的类型为:NSConcreteValue,我们需要转化为我们熟知的CG类型(CGPoint,CGRect等)。以下以CGPoint为例
UIScrollView *scrolView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 200, 400)];
scrolView.contentSize = CGSizeMake(200, 800);
scrolView.backgroundColor = [UIColor greenColor];
[self.view addSubview:scrolView];
[RACObserve(scrolView, contentOffset) subscribeNext:^(id x) {
//此处接收的打印的x为NSConcreteValue
//如下转为CGPoint类型,若转化为CGRect,对应 [(NSValue *)x CGRectValue]
CGPoint point = [(NSValue *)x CGPointValue];
}];