gpt4 book ai didi

iphone - 单击 "back"按钮时 UINavigationController 应用程序崩溃

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:27:03 24 4
gpt4 key购买 nike

希望有人能帮助我。

didSelectRowAtIndexPath 方法中,我加载并推送详细 View Controller ,当您点击详细 View 中的“后退”按钮返回 Root View 时,应用程序将崩溃。没有错误日志或任何东西。

我 95% 确定它与过早发布的“游乐设施”对象有关,但无法弄清楚。

感谢您的帮助!

#import "RidesViewController.h"
#import "RideDetailViewController.h"
#import "JSON.h"

@implementation RidesViewController
@synthesize rides;

#pragma mark -
#pragma mark View lifecycle
- (void)viewDidLoad {

[super viewDidLoad];

self.tableView.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"table-view-background.png"]];

rides = [[NSDictionary alloc] init];

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"rides" ofType:@"JSON"];
NSData *jsonData = [NSData dataWithContentsOfFile:filePath];
NSString *responseString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

NSDictionary *results = [responseString JSONValue];

rides = [results objectForKey:@"rides"];

[rides retain];
}

#pragma mark -
#pragma mark Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

return [rides count];
}

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

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

cell.textLabel.text = [[rides valueForKey:@"title"] objectAtIndex:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

return cell;
}

#pragma mark -
#pragma mark Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

[tableView deselectRowAtIndexPath:indexPath animated:YES];

RideDetailViewController *rideDetailViewController = [[RideDetailViewController alloc] initWithNibName:@"RideDetailViewController" bundle:nil];

NSString *aTitle = [[NSString alloc] initWithString:[[rides valueForKey:@"title"] objectAtIndex:indexPath.row]];
NSString *aImagePath = [[NSString alloc] initWithString:[[rides valueForKey:@"imagePath"] objectAtIndex:indexPath.row]];
NSString *aDescription = [[NSString alloc] initWithString:[[rides valueForKey:@"description"] objectAtIndex:indexPath.row]];
NSString *aVideoPath = [[NSString alloc] initWithString:[[rides valueForKey:@"videoPath"] objectAtIndex:indexPath.row]];

[rideDetailViewController initWithTitle:aTitle imagePath:aImagePath description:aDescription videoPath:aVideoPath];

[self.navigationController pushViewController:rideDetailViewController animated:YES];

[rideDetailViewController release];
[aTitle release];
[aImagePath release];
[aDescription release];
[aVideoPath release];
}

#pragma mark -
#pragma mark Memory management
- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];
}

- (void)dealloc {
[super dealloc];
}


@end

最佳答案

在标题中定义您的 NSString,然后将它们放入 cellForRowAtIndexPath:

关于iphone - 单击 "back"按钮时 UINavigationController 应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4953657/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com