2016-07-03 41 views
0

Wenn ich ReactiveCocoa verwenden, ich möchte meinen tableView ‚s Rahmen beobachten, aber es kommt ein Problem:iOS: Gebrauchte Typ ‚CGRect‘ (auch bekannt als ‚struct CGRect‘), in dem arithmetischen oder Zeigertyp erforderlich ist

__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; 
}]; 

Ich weiß nicht, was dieses Problem erscheint.

+0

Was ist CGRext? Ich habe noch nie davon gehört. Was ist das Ergebnis des NSLog? – Fogmeister

+0

Es tut mir so leid, ich habe meine Frage bearbeitet. – aircraft

+0

Keine Sorge. Was ist das Ergebnis des Nslog in der ersten Zeile des Blocks? – Fogmeister

Antwort

2

Das Objekt x ist ein NSValue.

Sie müssen das CGRect daraus entpacken. Sie können es nicht einfach umsetzen. Versuchen

...

tmp_rect = [x CGRectValue]; 
+0

Danke, es hat für mich funktioniert. – aircraft