2014-02-28 85 views
-1

我試圖在self.view.parentview中顯示UIActionSheet。但我得到下面的警告,同時運行UIActionSheet showInView給出警告:無效的上下文0x0

<Error>: 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. 
<Error>: 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. 
<Error>: 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. 

代碼如下

self.dobActionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil,nil]; 
[self.dobActionSheet addSubview:self.doneForActionSheet]; 
[self.dobActionSheet addSubview:self.cancelForActionSheet]; 
[self.dobActionSheet addSubview:self.dobDatepicker]; 
[self.dobActionSheet showInView:self.parentViewController.view]; 

我已經把斷點。但在此行中得到此警告[self.dobActionSheet showInView:self.parentViewController.view]; ..

我已嘗試在Viewcontroller中呈現這是embedded in tabbarController的第一個索引。這就是爲什麼,努力表現與parentViewController.view代替self.view

注:我看作是同樣的問題here。但無法找到答案。

+0

嘗試使用[self.dobActionSheet showInView:self.view]; – iPatel

+0

我無法做到這一點。因爲這個視圖控制器被嵌入在第一個索引處的tabbarcontroller中。這是正確的方法嗎?任何方式嘗試這一點,但得到相同的錯誤..! – Mani

+0

可能的重複:http://stackoverflow.com/a/19111512/544265 – c0ming

回答

5
actionSheet = [[UIActionSheet alloc] initWithTitle:@"Title" 
               delegate:self 
            cancelButtonTitle:nil 
           destructiveButtonTitle:nil 
            otherButtonTitles:@"Ok"]; 

,而不是零值,使用@ 「」

actionSheet = [[UIActionSheet alloc] initWithTitle:nil 
delegate:nil 
cancelButtonTitle:@"" 
destructiveButtonTitle:nil 
otherButtonTitles:nil]; 
+0

操作表顯示標題..所以我嘗試用單個空格作爲標題。它正在工作。看到我的答案..謝謝你的U :) – Mani

+0

好吧,你可以做到這一點.. –

0

我已經解決了從@Sunny沙阿回答這個問題。我已經嘗試了他的回答,但在行動表上有title。相反,我嘗試使用下面的代碼(標題名稱爲單個空格)。

self.dobActionSheet = [[UIActionSheet alloc] initWithTitle:@" " delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil,nil]; 
相關問題