2011-10-18 37 views
0

我有一個tableview在自定義單元格被加載。自定義單元有一個按鈕,點擊其中一個pickerview將打開哪些將有選項可供選擇。去customcell從customcell

問題是,modalViewController方法不工作,它給出了以下錯誤。

Selector *sel = [[Selector alloc]initWithNibName:@"Selector" bundle:nil]; 
[self PresentModalViewController:sel animated:YES]; 
error:property presentModalViewController not found on object of type CustomCell *...and selector is the pickerview controller class...the method is written in ibaction function in customcell.m file 

v如何調用自定義單元格中的其他視圖?

感謝

回答

2

首先,命名類「選擇器」是一個可怕的混亂思想。你應該使用更具描述性的東西,還有一些不是obj-c關鍵字的東西。

至於你的問題,我認爲你應該使用委託來從你的單元格視圖到控制器的引用。在您的自定義單元格視圖類中,執行如下操作:

@property (nonatomic, assign) id delegate; 

// implementation 
@synthesize delegate = _delegate; 

// in your cell... method 
[self.delegate presentPicker]; 

在這裏,代表ivar會指向您的視圖控制器。要設置了,找到你的Alloc你的地方,並做

ACell *aCell = [ACell alloc] init]; 
aCell.delegate = self; 
+0

@達倫presentPicker是pickercontroller的名字嗎?..如果是的話[self.delegate presentPicker]沒有出現在我的自定義單元格..我有一個按鈕行動,我在寫這個?是好的..和最後一塊代碼,它是寫在pickercontroller或主視圖控制器的自定義單元格被分配內存.. –