2011-10-18 21 views
0

我有一個連接到IBAction方法的自定義單元中的按鈕 - downloading。當我點擊按鈕,然後我得到單擊單元格的索引路徑,並從該索引路徑中獲取數組的值。這是我的代碼從其他控制器返回後沒有得到字符串的值

-(IBAction)downloading:(id)sender 
{ 
    if(abletodownload){ 
classvalue = 1; 
UITableViewCell *clicked = (UITableViewCell *)[[sender superview] superview]; 
clickedPath = [self.tableview indexPathForCell:clicked];   
idstring =[arr7 objectAtIndex: clickedPath.row]; 
NSLog(@"idstring.....%@",idstring); 

urlstring = [arr6 objectAtIndex: clickedPath.row]; 
holdingurlstring =[[NSString alloc]initWithString:urlstring]; 
NSLog(@"urlstring...%@",holdingurlstring); 

titlestring = [arr2 objectAtIndex: clickedPath.row]; 
holdingtitlestring = [[NSString alloc]initWithString:titlestring]; 
NSLog(@"titlestring.....%@",titlestring); 

objInAppClass = [[InAppClass alloc]init]; 
[objInAppClass canmakepayment];} 

然後我分配並啓動InAppClass並執行InAppPurchase的所有功能。 bur當我從InAppClass返回時,我無法得到holdurlstringholdtitlestring的值在其他部分這裏是代碼。

else{ 

    abletodownload = TRUE; 
    NSLog(@"holdurlstring...%@",holdurlstring); 
    NSLog(@"holdtitlestring.....%@",holdtitlestring); 

    [self connectionwithrequest]; 
} 
} 

總之,我需要在從InAppClass返回後保存urlstring和titlstring的值。該怎麼辦?

回答

0
  1. 自定義單元類中創建視圖控制器的一個實例,你想要的價值和綜合它。 HomeViewControllerClassName * containerView;

  2. 在視圖控制器中,當你在自定義單元格中調用它的容器屬性爲self時。 ((CustomCellClassName *)cell).containerView = self;

    在我們的視圖控制器中創建一個方法 - (void)getDetailsFromCustomCell:(NSUrl *)urlString;

  3. 4米取其地方ü希望的數據要被髮送的呼叫的viewController方法

    [containerView getDetailsFromCustomCell:urlstring];

同樣的方法你可以傳遞任何沒有值的控制器類。

所有最好的...

+0

:我沒有使用任何自定義單元類。我創建了單獨的空筆尖,我從裏面放置了帶有標識符和按鈕的UITableViewCell。然後我在cellForRowAtIndexPath方法中調用該nib。 – Ketan

+0

其次我只是想'holdurlstring'和'holdtitlestring'的值在其他部分,因爲他們是如果部分。在If部分顯示將控制權移交給inappclass之前的值。但後來不是。 – Ketan

相關問題