UITableView细节过渡

编程入门 行业动态 更新时间:2024-10-26 04:28:15
本文介绍了UITableView细节过渡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试做一个详细列表,但我不能这样做,我不明白为什么。

I'm tryin to do a detail list but i can't do it and i don't understand why.

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

Is a storyboard, the storyboard is connected ok. Is only one tableView and View controller for detail.

我正在尝试推入一个单元格并转到详细信息屏幕,在详细信息类中我有两个属性但当我推入单元格时,应用程序崩溃并且我有一个例外:

I'm trying to push in one cell and go to the detail screen and at the detail class i've two propertys but when i push in a cell, the app crash and i've a exception:

由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'无法加载NIB捆绑:'NSBundle(已加载)',名称为'GasolDetalleVCViewController'' ***第一次抛出调用堆栈:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'GasolDetalleVCViewController'' *** First throw call stack:

这些类是:

表格控制器.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

详情类控制器.h:

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

详情类控制器.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外部重命名某些文件时,可能会发生此错误。要解决它,您只需从项目中删除文件(右键单击 - 删除和删除参考)您重新导入项目中的文件,一切都会好的!

This error can occure when you rename some files outside XCode. To solve it you can just remove the files from your project (Right Click - Delete and "Remove Reference") You re-import the files in your project and everything will be ok !

更多推荐

UITableView细节过渡

本文发布于:2023-11-23 01:46:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619668.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:细节   UITableView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!