gpt4 book ai didi

iphone - 以编程方式添加的按钮使应用程序崩溃

转载 作者:搜寻专家 更新时间:2023-10-30 20:27:21 24 4
gpt4 key购买 nike

当我按下我的按钮时,应用程序崩溃了。即使在我以编程方式创建按钮或尝试通过 XIB 为我需要按钮的类添加按钮时也会发生。

我启用了 Zombies,我从控制台获得的调试消息是:

2010-10-27 00:47:28.643 CarTrawler[1537:207] * -[ReceiptView performSelector:withObject:withObject:]: 消息发送到释放实例 0x76cb700

但是按钮被添加到 View 中。所以我不明白问题是什么。该类代表一张收据,因此根据应用程序中有多少收据来调用它。

- (void)viewDidLoad {
[super viewDidLoad];
self.refLabel.text = theBooking.confID;
self.carTypeLabel.text = theBooking.vehMakeModelName;
//self.amountLabel.text = [NSString stringWithFormat:@"€22.00"];
self.locationLabel.text = [NSString stringWithFormat:@"%@, %@",
theBooking.locationName, theBooking.locationAddress];
self.numberLabel.text = theBooking.locationPhoneNumber;

self.dateTimeLabel.text = theBooking.puDateTime;
self.doDateTimeLabel.text = theBooking.doDateTime;
DLog(@"Dropoff date time label is %@", theBooking.doDateTime);

CTTableViewAsyncImageView *thisImage = [[[CTTableViewAsyncImageView alloc]
initWithFrame:CGRectMake(0.0, 0.0, 64.0, 40.0)] autorelease];
[vendorImage addSubview:thisImage];
NSURL *url = [NSURL URLWithString:theBooking.vehPictureUrl];
[thisImage loadImageFromURL:url];

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(220, 270, 60, 30);
[button setTitle:@"Email!" forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonPressed)
forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];

}


-(void)buttonPressed {
NSLog(@"Button Pressed!");
}

有人可以向我解释一下我忽略了什么吗?

最佳答案

我认为你需要保留你的按钮。

你发帖已经有一段时间了,你弄明白了吗?

关于iphone - 以编程方式添加的按钮使应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4028818/

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