我开发了一个故事板iPhone应用程序,我有一个问题,我无法解决 . 我在这里寻找答案和谷歌搜索,但仍然无法找到补救措施,提前感谢任何帮助或答案 .

我有一个mainViewController,它使用tableView和单个单元格转换为viewController . 该表显示从数组填充的产品列表,并导航到显示另一个数组中的图像的detailViewController . tableView和detail控制器工作正常 . 我的问题是我的productViewController上的后退按钮 . 当您第一次到达产品表时,后退按钮会返回到mainViewController,导航到detailViewController后,返回按钮会返回到最后一个视图而不是MainViewController . 我尝试过使用segues,IBAction代码等 . 当我在故事板中连接segue时,它只会崩溃应用程序 . 我在同一个应用程序中的其他viewControllers上使用了完全相同的segue,它们按预期执行 . 问题只出在这一个viewController上 .

#import "productViewController.h"
#import "detailViewController.h"
#import "MainViewController.h"

@interface productViewController ()

{
    int _selectedRowNum;
}

@property (strong, nonatomic)NSString *list;

@end


@implementation productViewController

@synthesize images;
@synthesize details;
@synthesize detailTableView;



- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
  }

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.


   self.productTableView.delegate = self;
   self.productTableView.dataSource = self;


   images = [[NSArray alloc]initWithObjects:
               @"flor-sil",
               @"flor-shield",
               @"flor-finish",
               @"flor-finish-lg",
               @"flor-guard",
               @"flor-color",
               @"pc-5614",
               @"rsg",
               @"flor-cure",
               @"flor-clean",  nil];

    details = [[NSArray alloc]initWithObjects:
                @"sil-detail",
                @"flor-shield-detail",
                @"finish-detail",
                @"finish_lg-detail",
                @"ex-detail",
                @"color-detail",
                @"pc-5614-detail",
                @"rsg-detail",
                @"flor-cure-detail",
                @"flor-clean-detail",   nil];

    }

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

这是同一个viewController的下一节;

#pragma mark - Table View Delegate 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return images.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:    (NSIndexPath *)indexPath

        {
            static NSString *cellIdentifier = @"BasicCell";
            UITableViewCell *myCell = [tableView  dequeueReusableCellWithIdentifier:cellIdentifier];


        long row = indexPath.row;

        myCell.imageView.image = [UIImage imageNamed: images[row]];


            return myCell;
        }



-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath     *)indexPath

{
   _selectedRowNum = indexPath.row;

   [self performSegueWithIdentifier:@"detailSegue" sender:self];

}


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

  {

        detailViewController *detailVC = segue.destinationViewController;

        detailVC.imgName = details [_selectedRowNum];

        NSLog(@"Segue");
    }

- (IBAction)back:(id)sender {
    [self dismissViewControllerAnimated:YES completion:NULL];
}

@end

我试过的其他代码;

-(IBAction) back: (id)sender {
[self.navigationController popToRootViewControllerAnimated:YES];
}

替换“self dismissViewController”时使用此代码不执行任何操作 . 没有反应 .