我正在使用操作表來顯示供用戶選擇的數據列表。問題是顯示使用[self.actionSheet showInView:self.view];
的操作表正在導致幾個CGContext錯誤。同樣的代碼在iOS中行之有效6.顯示操作表導致CGContext無效上下文錯誤
代碼:
self.actionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[self.actionSheet setActionSheetStyle:UIActionSheetStyleBlackOpaque];
CGRect tableFrame = CGRectMake(0, 40, 320, 214);
self.tableView = [[UITableView alloc] initWithFrame:tableFrame style:UITableViewStylePlain];
self.tableView.dataSource = self;
self.tableView.delegate = self;
[self.actionSheet addSubview:self.tableView];
UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Done"]];
closeButton.momentary = YES;
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
closeButton.tintColor = [UIColor redColor];
[closeButton addTarget:self action:@selector(dismissActionSheet:) forControlEvents:UIControlEventValueChanged];
[self.actionSheet addSubview:closeButton];
[self.actionSheet showFromView:self.view];
[UIView beginAnimations:nil context:nil];
[self.actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
[UIView commitAnimations];
錯誤:
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.
更新:
到cancelButtonTitle設置爲@ 「」 導致的解決方法這對我的UI問題:
原始代碼來自另一個stackoverflow答案,請參閱https://stackoverflow.com/a/2074451/654870。
確實,我們試圖將行動表用作窮人的iPhone彈出窗口。由於@ kyle的回答,我們做了一些重構,現在我們只是將內容呈現在模態UINavigationController中。 –