我在 UIActionSheet 中有一个 UIPickerView,并按照许多其他人在 SO 中建议的方式完成了该操作:
Add UIPickerView & a Button in Action sheet - How?
how to add UIPickerView in UIActionSheet
直到现在,当我在 iOS 7 上测试我的应用程序时,这些解决方案都运行良好。它仍然可以运行,但我在 Xcode 运行时收到了很多“无效上下文 0x0”警告。
The errors are coming with a nice message too:
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.
可能是 Apple 最终想停止这种解决方案,还是我们可以解决或解决这个问题?
最佳答案
此“无效上下文 0x0”警告的解决方法是使用非 nil 标题初始化 UIActionSheet(非 nil 按钮也可以解决错误,但会导致视觉伪像)。
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@""
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
然后您需要调整操作表的框架以使其在 iOS7 和以前的版本中正确定位(确保在 showInView 方法之后执行此操作)。
CGRect newFrame = actionSheet.frame;
newFrame = self.view.bounds.size.height - myCustomPicker.frame.size.height;
newFrame = myCustomPicker.frame.size.height;
actionSheet.frame = newFrame;
关于iphone - 在 UIActionSheet 中添加 UIPickerView 时,iOS 7 上出现无效上下文错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19011170/