请遵循以下代码:

DetailsViewController.h

#import <UIKit/UIKit.h>

@interface DetailsViewController : UIViewController

@property (strong , nonatomic) IBOutlet UILabel *TitleLabel;
@property (strong , nonatomic) IBOutlet UILabel *DescriptionLabel;
@property (strong , nonatomic) IBOutlet UIImageView *ImageView;
@property (strong , nonatomic) NSArray *DetailModal;

@end


TableViewController.m

#import "DetailsViewController.h"

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 if ([[segue identifier] isEqualToString:@"ShowDetails"]) {

   DetailsViewController *detailsviewcontroller = [segue destinationViewController];
   NSIndexPath *myIndexPath = [self.tableView indexPathForSelectedRow];
   int row = [myIndexPath row];
   NSLog(@"Tanim = %i",row);
   detailsviewcontroller.DetailModal = @[_Title[row],_Description[row], _Images[row]];

}
}


我可以使用上面的代码,还可以从故事板上设置标记标识符“ ShowDetails”,但不要转到detailsViewController窗口。有人可以帮忙解决这个问题或建议我吗?

最佳答案

我已经看到您的错误。您链接了此脚本的情节提要中的ViewController不是我认为的类DetailViewController。还要检查Segue名称是否为“ ShowDetails”

08-05 21:44