2012-11-17 30 views
2

在我的tableview上執行搜索並選擇一行後,詳細視圖控制器(MOVdetailViewController)只更新名稱而不是信息(地址,網站和其他東西)。它位於我設置爲開關的MDVC.lodgeNumber中。我現在認爲這是不可能的,因爲詳細信息存儲在交換機中。所有的反饋是極大的讚賞開關prepareForSegue函數不返回搜索後的原始切換結果

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 

{ 
    if ([segue.identifier isEqualToString:@"lodgedetail"]) { 
     MOVDetailViewController *destViewController = segue.destinationViewController; 
     MOVDetailViewController * MDVC = [[MOVDetailViewController alloc] init]; 


     NSIndexPath * path = [self.tableView indexPathForSelectedRow]; 
     NSString * thelodge = [filteredList objectAtIndex:path.row]; 

     MDVC = [segue destinationViewController]; 
     MDVC.lodgeNumber = path.row; 
     MDVC.lodgeName = thelodge; 



     NSIndexPath *indexPath = nil; 

     if ([self.searchDisplayController isActive]) { 
      indexPath = [self.searchDisplayController.searchResultsTableView 
          indexPathForSelectedRow]; 
      destViewController.lodgeName = [filteredList objectAtIndex:indexPath.row]; 



     } else { 
      indexPath = [self.tableView indexPathForSelectedRow]; 
      destViewController.lodgeName = [lodgeList objectAtIndex:indexPath.row]; 
     } 
     } 
    } 

例子:

self.title = lodgeName;  
    switch (lodgeNumber) { 
     case 0: 
      //Abingdon Lodge No. 48 
      address.text = @"325 W Main Street Abingdon, Virginia 24210"; 
      website.text = @"http://www.grandlodgeofvirginia.org/lodges/48/"; 
      statedc.text = @"Abingdon Lodge No. 48 holds it's stated communication on the    
          2nd Monday of the month at 7:30 PM. If there are 
          any exceptions to the regular meeting day or time, 
          they are posted on the Lodge website."; 

     lodgehistory.text = @"According to the earliest records the Abingdon Lodge had 
       its origin 「At a meeting held at the house of 
       James White in the town of Abingdon, on October 3, 1796.」 The record 
       states that a dispensation had been given by the Grand Master of 
       Masons in Virginia and the following were present: William King, 
       Master; Daniel Murphy, Past Master; Robert Johnson, Past Master; 
       Charles Carson, Past Master, and William Preston Skillern. For more 
       information on the Lodge History please see the Lodge website."; 

     break; 
+0

查希爾·艾哈邁德,你知道這是可能的嗎? – Apps

+0

哪個方法包含'switch'語句? –

+0

(lodgeNumber).... tableview保存旅館的名稱,詳細視圖保存LodgeNumber,它保存用戶執行搜索後不更新的信息。切換方法是(lodgeNumber)但是,self.title AKA lodgeName正在更新。我不確定爲什麼其他數據不是。確定後,詳細數據只顯示情況0,而不顯示其他情況。 – Apps

回答

0
MOVDetailViewController *MDVC = segue.destinationViewController; 
NSIndexPath * path = [self.tableView indexPathForSelectedRow]; 
NSString * thelodge = [filteredList objectAtIndex:path.row]; 

MDVC.lodgeName = thelodge; 
MDVC = [segue destinationViewController]; // REMOVE THIS LINE 
MDVC.lodgeNumber = path.row;