0

不会撒谎,我正在尝试按照书中的教程进行操作,但我无法通过此警告。

Incompatible pointer types initializing 'CGContextRef *' (aka 'struct CGContext **') with an expression of type 'CGContextRef' (aka 'struct CGContext *')

违规行是:CGContextRef *imageContext = UIGraphicsGetCurrentContext();

- (IBAction)hide:(id)sender {
    CGContextRef *imageContext = UIGraphicsGetCurrentContext();
    if (_myIcon.alpha == 1) {
        [UIView beginAnimations:nil context:imageContext];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
        [UIView setAnimationDuration:3];
        [UIView setAnimationDelegate:self];
        _myIcon.alpha = 0.0;
        [_hideButton setTitle:@"Show" forState:UIControlStateNormal];
    } else if (_myIcon.alpha == 0.0) {
        [UIView beginAnimations:nil context:imageContext];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
        [UIView setAnimationDuration:3];
        [UIView setAnimationDelegate:self];
        _myIcon.alpha = 1;
        [_hideButton setTitle:@"Hide" forState:UIControlStateNormal];
    }

    [UIView commitAnimations];

}
4

1 回答 1

0

CGContextRef不是一个类。你不需要指针。改变这个:

CGContextRef *imageContext = UIGraphicsGetCurrentContext();

至:

CGContextRef imageContext = UIGraphicsGetCurrentContext();

查看该UIGraphicsGetCurrentContext功能的文档。返回类型是CGContextRef,不是CGContextRef *

于 2013-05-31T16:21:31.083 回答