gpt4 book ai didi

iphone - 表格 View 崩溃

转载 作者:行者123 更新时间:2023-12-03 21:22:43 24 4
gpt4 key购买 nike

由于某种原因,这个 UITableView 不断崩溃,似乎 UITableView 由于某种原因无法显示秒字符串,但我不知道为什么......请在这里帮助我,因为我不知道我可能做错了什么.....谢谢!!

#import "SettingsView.h"

@implementation SettingsView

- (void)viewWillAppear:(BOOL)animated {

[super viewWillAppear:animated];
transmissionSetup = [[TransmissionSetupViewController alloc] initWithNibName:@"TransmissionSetupViewController" bundle:nil];
transmissionSetup.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
NSLog(@"%i", [self getMinutes]);
[self setSeconds:10];
secondsString = [NSString stringWithFormat:@"%i", [self getSeconds]];
[self.tableView reloadData];
}

#pragma mark Table view methods

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
}

if (indexPath.section == 0) {
cell.textLabel.text = @"Every:";
cell.detailTextLabel.text = secondsString;
}
// Set up the cell...

return cell;
}

@end

最佳答案

您使用自动释放的字符串初始化您的 secondString - 因此不能保证它在当前范围之外有效。您需要在初始化时保留它(并且不要忘记稍后释放)

我建议你看看objective-c properties用于访问 ivars。

关于iphone - 表格 View 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3264686/

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