2011-12-27 35 views
0

我想讓showEventDate方法讓數據像下面的tableview那樣傳入,我該怎麼做?我不能在該方法中放入indexPath。謝謝。Xcode JSON代理

-(void)showEventDate 
{ 
     EventView *rvc = [[EventView alloc]initWithNibName:@"EventView" bundle:nil]; 
     [navController pushViewController:rvc animated:YES]; 
     [rvc release]; 
} 

// Display a details screen for the selected holiday/row. 
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath    *)indexPath 
{ 
    Event *holiday = [dataSource holidayAtIndexPath:indexPath]; 
    HolidaysDetailViewController *vc = [[[HolidaysDetailViewController alloc]    initWithHoliday:holiday] autorelease]; 
    [navController pushViewController:vc animated:YES]; 
    } 

回答

0

我假設你想indexRow從一個UITableView傳遞給showEventDate。我要去刺一下它..首先實現委託方法didSelectRowAtIndexPath :.然後將'indexPath'傳遞到你想要的任何地方:即showEventdate。

-(void)showEventPath: (NSIndexPath *)indexPath 
{ 
    // your code here... 
} 
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    [self showEventPath:indexPath]; 
} 
+0

否,showEventDate是調用一個按鈕.navigationItem.leftBarButtonItem = [[[ALLOC的UIBarButtonItem] initWithTitle的方法:@ 「事件列表」 樣式:UIBarButtonItemStyleBordered目標:自動作:@selector(showEventDate)]自動釋放]。但是當我點擊按鈕時,數據wasnt傳入,顯示所有空值,因此我需要把該方法的索引路徑將數據推入按鈕 – user1116989 2011-12-27 03:16:38