<Error>: CGContextRestoreGState

<Error>: CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.

出错原因:设置app的状态栏样式的使用使用了旧的方式,在info.plist里面设置了View controller-based status bar appearance为NO,默认为YES,一般式iOS6的时候使用这种方式,iOS7,8也兼容,但是到了iOS9就报了警告。修改方式将View controller-based status bar appearance设置为YES,然后使用新的方式来实现状态栏的样式。
ios7之后的方法
  • - (UIStatusBarStyle)preferredStatusBarStyle;

  • - (UIViewController *)childViewControllerForStatusBarStyle;

  • - (void)setNeedsStatusBarAppearanceUpdate

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
对不起,我之前的回答有误。`nvinfer1::IRuntime`确实没有`getLastError()`函数。如果您想要获取错误信息,可以使用`nvinfer1::IHostMemory`对象来捕获反序列化引擎的错误信息。以下是一个修改后的示例代码片段: ``` int main() { // Create the inference runtime nvinfer1::IRuntime* runtime = nvinfer1::createInferRuntime(...); // Deserialize the CUDA engine std::ifstream engineFile("engine.plan", std::ios::binary); engineFile.seekg(0, std::ios::end); const size_t fileSize = engineFile.tellg(); engineFile.seekg(0, std::ios::beg); std::vector<char> engineData(fileSize); engineFile.read(engineData.data(), fileSize); nvinfer1::IHostMemory* engineMemory = runtime->deserializeCudaEngine(engineData.data(), fileSize); // Check if deserialization was successful if (engineMemory == nullptr) { std::cerr << "Error: Failed to deserialize CUDA engine" << std::endl; return 1; } // Check if there were any errors during deserialization if (engineMemory->size() == 0) { std::cerr << "Error: " << std::string(static_cast<char*>(engineMemory->data()), engineMemory->size()) << std::endl; return 1; } // Deserialize the engine from the host memory nvinfer1::ICudaEngine* engine = runtime->deserializeCudaEngine(engineMemory->data(), engineMemory->size(), nullptr); // ... } ``` 在上述示例中,`deserializeCudaEngine()`函数返回一个`nvinfer1::IHostMemory`对象,该对象包含了反序列化引擎的状态。如果返回的`IHostMemory`对象的大小为0,则说明发生了错误。此时,您可以使用`std::string(static_cast<char*>(engineMemory->data()), engineMemory->size())`来获取错误消息。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值