2011-02-05 54 views
0

我確定這是一個簡單直觀的應用程序,但不確定最佳方式是什麼(並且這是全新的)。我有一個導航控制器與UITableViewController(所有在UITabViewController中運行)。使用UITableView和詳細視圖導航

當用戶點擊一行時,應用程序進入詳細視圖。現在我正在嘗試將左右滑動手勢鏈接到導航到上一個和下一個記錄。但是,從詳細視圖中做到這一點的正確方法是什麼?返回我的TableViewController的最簡單方法是什麼?

一個相關的問題是我如何將'下拉'鏈接到與導航控制器'後退'按鈕相同的動作。

我希望以上是有道理的。感謝提前一百萬!


我有什麼樣的工作,在我喜歡的方式,但它是非常笨拙。 當調用DetailView時,我將參數指向'self'和當前'selectedRow'。然後,當刷新完成後,我在tabelViewController上調用函數'moveToNextRecord'(提供指針)並將selectedRow作爲參數。然後在tableViewController中調用selectRowAtIndexPath和didSelectRowAtIndexPath。

-(void)moveToNextRecord:(NSIndexPath*) selectedRow{ 
    //[self.navigationController popViewControllerAnimated:YES]; 
    //NSIndexPath *selectedRow = [self.tableView indexPathForSelectedRow]; 
    NSUInteger row = selectedRow.row; 
    NSUInteger section = selectedRow.section; 
    ++row; 
    if(row >= [self.tableView numberOfRowsInSection:selectedRow.section]) 
    { 
     row = 0; 
     ++section; 
     if(section >= [self.tableView numberOfSections]) 
     { 
      row = 0; 
      section = 0; 
     } 
    } 
    [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:section] animated:YES scrollPosition:UITableViewScrollPositionMiddle]; 
    [self tableView:self.tableView didSelectRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:section]]; 
} 

這似乎工作,但問題是,下一個記錄是在上一個之後插槽。這意味着後退按鈕使我回到上一條記錄,而不是返回到表格視圖。所以我想我應該告訴ViewController我不想堆疊它們,但基本上是回去,然後選擇下一行,同時直接從一個detailView顯示動畫到下一行。這有道理嗎?

([self.navigationController popViewControllerAnimated:YES]。作爲第一小說似乎並沒有工作,因爲它沒有適當的流量)

回答

0

我正在轉向PageControl解決方案,因爲它是一個大大改進的用戶體驗,因爲頁面實際上在用戶滑動的同時移動。有了上面的建議,我需要覆蓋「後退」按鈕,並手動填充ViewController堆棧,以便在進行正確的滑動時允許從左到右的過渡(並且僅在滑動完成時發生)

0

從細節來看,一旦你認識到的手勢,然後調用:

[self.navigationController popViewControllerAnimated:YES];

這將導航回來。

+0

謝謝你!任何關於瀏覽tableView的想法?我無法讓它工作。 – 2011-02-05 19:33:24

相關問題