Ios 显示操作表会导致CGContext无效上下文错误
我使用actionsheet显示数据列表,供用户选择。问题在于使用Ios 显示操作表会导致CGContext无效上下文错误,ios,uiactionsheet,cgcontext,Ios,Uiactionsheet,Cgcontext,我使用actionsheet显示数据列表,供用户选择。问题在于使用[self.actionsheet showInView:self.view]显示操作表导致多个CGContext错误。同样的代码在iOS 6中运行良好 代码: 错误: CGContextSetFillColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an in
[self.actionsheet showInView:self.view]显示操作表代码>导致多个CGContext错误。同样的代码在iOS 6中运行良好
代码:
错误:
CGContextSetFillColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
CGContextSetStrokeColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
CGContextSaveGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
CGContextSetFlatness: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
CGContextAddPath: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
CGContextDrawPath: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
CGContextRestoreGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
更新:
将CancelButtontile设置为@“”的解决方法会导致我出现此UI问题:
原始代码来自另一个stackoverflow答案,请参见。我相信这里的答案是UIActionSheet不打算以这种方式使用,因此可能会产生类似的副作用。从中可以看出,“UIActionSheet不是设计为子类的,也不应该向其层次结构添加视图。”
虽然这在iOS 6中并没有给我带来问题,但iOS 7中有一些明显的变化,我更倾向于走另一条路,而不是尝试做一些与文档相矛盾的事情。请注意,解决方法可能是将@传递给CancelButtontile,而不是nil,但这会导致其他UI问题,并且可能不会得到Apple的批准
替代解决方案:
创建您自己的视图并以模块化的方式呈现-我简单地展示了一种方法
(iOS 7尚未更新)
我相信这里的答案是,UIActionSheet不打算以这种方式使用,因此可能会产生这样的副作用。从中可以看出,“UIActionSheet不是设计为子类的,也不应该向其层次结构添加视图。”
虽然这在iOS 6中并没有给我带来问题,但iOS 7中有一些明显的变化,我更倾向于走另一条路,而不是尝试做一些与文档相矛盾的事情。请注意,解决方法可能是将@传递给CancelButtontile,而不是nil,但这会导致其他UI问题,并且可能不会得到Apple的批准
替代解决方案:
创建您自己的视图并以模块化的方式呈现-我简单地展示了一种方法
(iOS 7尚未更新)
Kyle,在使用@之后,您还有什么其他UI问题
在我使用了下面的代码之后,它对我来说工作得很好。我不使用tableview,我使用pickerview作为子视图
self.startSheet=[[UIActionSheet alloc]initWithTitle:nil
delegate:nil
cancelButtonTitle:@""
destructiveButtonTitle:nil
otherButtonTitles:nil];
Kyle,在使用@之后,您还有什么其他UI问题
在我使用了下面的代码之后,它对我来说工作得很好。我不使用tableview,我使用pickerview作为子视图
self.startSheet=[[UIActionSheet alloc]initWithTitle:nil
delegate:nil
cancelButtonTitle:@""
destructiveButtonTitle:nil
otherButtonTitles:nil];
下面是我给出的一个类似的答案,效果很好
self.actionSheet = [[UIActionSheet alloc] initWithTitle:@""
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
但是,这会弄乱动作表顶部的图形/绘图,因此,如果您还没有添加的背景,只需添加此代码即可为您提供默认动作表外观
UIView *background = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
background.backgroundColor = [UIColor colorWithRed:204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:1];
[self.actionSheet addSubview:background];
然后,在自定义操作表中添加您想要的任何其他内容。以下是我在一个类似的操作表上给出的答案,效果很好
self.actionSheet = [[UIActionSheet alloc] initWithTitle:@""
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
但是,这会弄乱动作表顶部的图形/绘图,因此,如果您还没有添加的背景,只需添加此代码即可为您提供默认动作表外观
UIView *background = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
background.backgroundColor = [UIColor colorWithRed:204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:1];
[self.actionSheet addSubview:background];
然后,在自定义的操作表中添加任何您想要的内容。事实上,我们正试图将操作表用作穷人的iPhone popover。多亏了@kyle的回答,我们做了一些重构,所以现在我们只是在一个模态UINavigationController中呈现内容。事实上,我们正试图将动作表用作穷人的iPhone popover。多亏了@kyle的回答,我们进行了一些重构,所以现在我们只需在一个模态UINavigationController中呈现内容。@到底发生了什么事?背景仍然是透明的ios7@BraveS到底发生了什么?ios7中的背景仍然是透明的