xCode CGContextSaveGState:无效的上下文0x0错误 [英] xCode CGContextSaveGState: invalid context 0x0 Error

查看:281
本文介绍了xCode CGContextSaveGState:无效的上下文0x0错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将xCode更新为7.0。我的代码以前工作过,但现在我得到了:

I just updated xCode to 7.0. My code was working before but now am I getting:


CGContextSaveGState:无效上下文0x0。如果要查看回溯,请设置CG_CONTEXT_SHOW_BACKTRACE环境变量。

CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.

在我的应用程序中,我有一个显示图像/视频的收件箱一旦选择了消息单元格。在消息显示正常之前,但在更新后它们不再显示。这是有效错误还是Apple错误?涉及的代码位于下面。

In my application I have an inbox that displays an image/video once the message cell is selected. Before the messages were displaying fine but upon updating they no longer show. Is this a valid error or an Apple bug? The involved code is placed below.

InboxTableViewController.m

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    self.selectedMessage = [self.messages objectAtIndex:indexPath.row];

    // mark message as read
    NSMutableArray *readByIds = [NSMutableArray arrayWithArray:[self.selectedMessage objectForKey:@"readBy"]];

    if ([readByIds containsObject:[[PFUser currentUser] objectId]]) {
        // message has already been read. do nothing
    }else {
        // message was unread. mark it as read now.
        [readByIds addObject:[[PFUser currentUser] objectId]];
        [self.selectedMessage setObject:readByIds forKey:@"readBy"];
        [self.selectedMessage saveInBackground];
    }


    NSString *fileType = [self.selectedMessage objectForKey:@"fileType"];
    if ([fileType isEqualToString:@"image"]) {
        // file type is image
        [self performSegueWithIdentifier:@"showImage" sender:self];
    } else {
        // file type is video
        PFFile *videoFile = [self.selectedMessage objectForKey:@"file"];
        NSURL *fileUrl = [NSURL URLWithString:videoFile.url];
        self.moviePlayer.contentURL = fileUrl;
        [self.moviePlayer prepareToPlay];
        [self.moviePlayer thumbnailImageAtTime:0 timeOption:MPMovieTimeOptionNearestKeyFrame];

        // add it to the view controller so we can see it
        [self.view addSubview:self.moviePlayer.view];
        [self.moviePlayer setFullscreen:YES animated:YES];
    }

}

...

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"showLogin"]) {
        LoginViewController *lvc = (LoginViewController *)segue.destinationViewController;
        [lvc setHidesBottomBarWhenPushed:YES];
        lvc.navigationItem.hidesBackButton = YES;
        //[segue.destinationViewController setHidesBottomBarWhenPushed:YES];
    } else if ([segue.identifier isEqualToString:@"showImage"]) {
        ImageViewController *ivc = (ImageViewController *)segue.destinationViewController;
        [ivc setHidesBottomBarWhenPushed:YES];
        ivc.message = self.selectedMessage;
    }
}

ImageViewController.m

- (void)viewDidLoad {
    [super viewDidLoad];

    NSString *senderName = [self.message objectForKey:@"senderFullName"];
    self.navigationItem.title = senderName;

    // download image from Parse.com
    PFFile *imageFile = [self.message objectForKey:@"file"];
    NSURL *imageFileUrl = [[NSURL alloc] initWithString:imageFile.url];
    NSData *imageData = [NSData dataWithContentsOfURL:imageFileUrl];

    //set the image view to the message image
    self.imageView.image = [UIImage imageWithData:imageData];
}


推荐答案

跟随链接更正了我的错误。

我特别使用了它:

<key>NSAppTransportSecurity</key>
<dict>
  <!--Include to allow all connections (DANGER)-->
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>

并将这些值设置在我的info.plist

and set these values in my info.plist

这篇关于xCode CGContextSaveGState:无效的上下文0x0错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆