初始化'CGContextRef *'的指针类型不兼容

时间:2013-05-31 16:06:55

标签: objective-c cgcontextref

不会撒谎,我正试图按照书中的教程进行操作,但我无法听到这个警告。

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

}

1 个答案:

答案 0 :(得分:0)

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

CGContextRef *imageContext = UIGraphicsGetCurrentContext();

为:

CGContextRef imageContext = UIGraphicsGetCurrentContext();

查看UIGraphicsGetCurrentContext函数的文档。返回类型为CGContextRef,而不是CGContextRef *

相关问题