【问题标题】:iOS:Used type 'CGRect' (aka 'struct CGRect') where arithmetic or pointer type is requirediOS:使用类型'CGRect'(又名'struct CGRect'),其中需要算术或指针类型
【发布时间】:2016-07-03 06:58:18
【问题描述】:

当我使用ReactiveCocoa时,我想观察我的tableView的框架,但是出现了一个问题:

__block CGRect tmp_rect;
[RACObserve(self, self.tableView.frame) subscribeNext:^(id x) {
    NSLog(@"%@",x);

    tmp_rect= (CGRect)x; // this line appear issue:
     'Used type 'CGRect' (aka 'struct CGRect') where arithmetic or pointer type is required'

    double width_radio = x.origin.x/[UIScreen mainScreen].bounds.size.width;

    back_nav.alpha = 1 - width_radio;
}];

我不知道这个问题出现了什么。

【问题讨论】:

  • 什么是 CGRext?没听说过。nslog的结果是什么。
  • 我很抱歉,我已经编辑了我的问题。
  • 不用担心。区块第一行的nslog结果是什么?
  • @Fogmeister 它记录:NSRect: {{152, 0}, {375, 667}}

标签: ios objective-c block reactive-cocoa


【解决方案1】:

对象 x 是一个 NSValue。

您需要从中解开 CGRect。你不能只是施放它。

试试……

tmp_rect = [x CGRectValue];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-19
    • 1970-01-01
    • 2017-02-10
    • 2015-01-01
    • 1970-01-01
    • 2023-03-31
    相关资源
    最近更新 更多