prepareForSegue函数在搜索后不返回原始开关结果

时间:2012-11-17 14:39:30

标签: iphone objective-c xcode ipad

在我的tableview上执行搜索并选择一行之后,详细视图控制器(MOVdetailViewController)仅更新名称而不是信息(地址,网站和其他内容)。它位于我设置为开关的MDVC.lodgeNumber中。我现在认为这是不可能的,因为详细信息存储在交换机中。非常感谢所有反馈

-(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;

1 个答案:

答案 0 :(得分: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;