UITableView细节过渡

我正在尝试做一个详细的清单,但我不能做到这一点,我不明白为什么。

是故事板,故事板连接好。 只有一个tableView和View控制器的细节。

我试图推入一个单元格,并进入详细信息屏幕和细节类我有两个propertys,但是当我推入一个单元格,应用程序崩溃,我有一个例外:

终止应用程序,由于未捕获的exception“NSInternalInconsistencyException”,原因:'无法加载捆绑NIB:'名为'GasolDetalleVCViewController''NSBundle(加载)'***第一个抛出调用堆栈:

这些课程是:

表格控制器.h:

#import <UIKit/UIKit.h> #import "GasolDetalleVCViewController.h" #import "DetallesGasol.h" @interface GasolTVCTableViewController : UITableViewController <UITableViewDataSource, UITableViewDelegate> { NSMutableArray *arrayNombrePrecio; NSInteger celdaPulsada; } @end 

表格控制器.m:

 #import "GasolTVCTableViewController.h" @interface GasolTVCTableViewController () @end @implementation GasolTVCTableViewController - (void)viewDidLoad { [super viewDidLoad]; arrayNombrePrecio = [NSMutableArray arrayWithCapacity:10]; DetallesGasol *textoCelda0 = [[DetallesGasol alloc]init]; DetallesGasol *textoCelda1 = [[DetallesGasol alloc]init]; DetallesGasol *textoCelda2 = [[DetallesGasol alloc]init]; DetallesGasol *textoCelda3 = [[DetallesGasol alloc]init]; DetallesGasol *textoCelda4 = [[DetallesGasol alloc]init]; DetallesGasol *textoCelda5 = [[DetallesGasol alloc]init]; DetallesGasol *textoCelda6 = [[DetallesGasol alloc]init]; DetallesGasol *textoCelda7 = [[DetallesGasol alloc]init]; DetallesGasol *textoCelda8 = [[DetallesGasol alloc]init]; DetallesGasol *textoCelda9 = [[DetallesGasol alloc]init]; textoCelda0.nombre = @"Autogas Alcorcon"; textoCelda0.precio = 0.71; textoCelda0.latitud = 40.3427359; textoCelda0.longitud = -3.8053231000000096; [arrayNombrePrecio addObject:textoCelda0]; textoCelda1.nombre = @"Autogas Atalayuela Vallecas"; textoCelda1.precio = 0.72; textoCelda1.latitud = 40.3707274; textoCelda1.longitud = -3.643952000000013; [arrayNombrePrecio addObject:textoCelda1]; textoCelda2.nombre = @"GLP Santa Eugenia"; textoCelda2.precio = 0.702; textoCelda2.latitud = 40.3831964; textoCelda2.longitud = -3.6279809000000114; [arrayNombrePrecio addObject:textoCelda3]; textoCelda3.nombre = @"Autogas Hispanidad"; textoCelda3.precio = 0.73; textoCelda3.latitud = 40.4678932; textoCelda3.longitud = -3.57114660000002; [arrayNombrePrecio addObject:textoCelda3]; textoCelda4.nombre = @"Autogas Mendez Alvaro"; textoCelda4.precio = 0.72; textoCelda4.latitud = 40.3911409; textoCelda4.longitud = -3.6750798000000486; [arrayNombrePrecio addObject:textoCelda4]; textoCelda5.nombre = @"Autogas Hipódromo"; textoCelda5.precio = 0.70; textoCelda5.latitud = 40.4635268; textoCelda5.longitud = -3.7577165999999806; [arrayNombrePrecio addObject:textoCelda5]; textoCelda6.nombre = @"Autogas Las Tablas"; textoCelda6.precio = 0.71; textoCelda6.latitud = 40.5074619; textoCelda6.longitud = -3.6695012000000133; [arrayNombrePrecio addObject:textoCelda6]; textoCelda7.nombre = @"GLP Alcorcon"; textoCelda7.precio = 0.73; textoCelda7.latitud = 40.3440681; textoCelda7.longitud = -3.838870799999995; [arrayNombrePrecio addObject:textoCelda7]; textoCelda8.nombre = @"Autogas Las Rozas"; textoCelda8.precio = 0.72; textoCelda8.latitud = 40.50090272885034; textoCelda8.longitud = -3.8722419196654982; [arrayNombrePrecio addObject:textoCelda8]; textoCelda9.nombre = @"Autogas Pinto"; textoCelda9.precio = 0.72; textoCelda9.latitud = 40.2550693; textoCelda9.longitud = -3.69782639999994; [arrayNombrePrecio addObject:textoCelda9]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return 10; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"celda"]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"celda"]; } DetallesGasol *detalleAux = [arrayNombrePrecio objectAtIndex:indexPath.row]; NSString *aux = [NSString stringWithFormat:@"%.3f", detalleAux.precio]; cell.textLabel.text = detalleAux.nombre; cell.detailTextLabel.text = aux; cell.textLabel.minimumFontSize = 12; cell.detailTextLabel.minimumFontSize = 12; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { GasolDetalleVCViewController *detailVC = [[GasolDetalleVCViewController alloc]initWithNibName:@"GasolDetalleVCViewController" bundle:nil]; DetallesGasol *detAux = [arrayNombrePrecio objectAtIndex:indexPath.row]; NSString *strAuxLat = [NSString stringWithFormat:@"%f", detAux.latitud]; NSString *strAuxLon = [NSString stringWithFormat:@"%f", detAux.longitud]; detailVC.latitud = strAuxLat; detailVC.longitud = strAuxLon; [self.navigationController pushViewController:detailVC animated:YES]; } //- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // // Get the new view controller using [segue destinationViewController]. // // Pass the selected object to the new view controller. // //// GasolDetalleVCViewController *gasol = segue.destinationViewController; //// gasol.detalle = [arrayNombrePrecio objectAtIndex:celdaPulsada]; // //} @end 

数组类对象.h:

 #import <Foundation/Foundation.h> @interface DetallesGasol : NSObject @property (strong, nonatomic) NSString *nombre; @property (assign) CGFloat precio; @property (assign) CGFloat latitud; @property (assign) CGFloat longitud; @end 

数组类对象.m:

 #import "DetallesGasol.h" @implementation DetallesGasol @end 

Detail类控制器.h:

 #import <UIKit/UIKit.h> @interface GasolDetalleVCViewController : UIViewController @property (strong, nonatomic) NSString *latitud; @property (strong, nonatomic) NSString *longitud; @end 

Detail类控制器.m:

 #import "GasolDetalleVCViewController.h" @interface GasolDetalleVCViewController () @end @implementation GasolDetalleVCViewController @synthesize latitud, longitud; - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. NSLog(@"Entra en viewDidLoad de GasolDetalleViewController"); NSLog(@"latitud: %@", latitud); NSLog(@"longitud: %@", latitud); } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end 

非常感谢

当您重命名XCode以外的某些文件时,可能会发生此错误。 要解决它,你可以从项目中删除文件(右键单击 – 删除和“删除参考”)您重新导入项目中的文件,一切都会好的!