当我按下我的按钮时,应用程序崩溃了。即使我以编程方式创建按钮或尝试通过XIB为我需要按钮的类添加一个按钮也会发生。
我启用了Zombies,我从控制台获得的调试信息是:
2010-10-27 00:47:28.643 CarTrawler [1537:207] * - [ReceiptView performSelector:withObject:withObject:]:消息发送到解除分配的实例0x76cb700
但按钮已添加到视图中。所以我不明白问题是什么。该类代表收据,因此根据应用程序中的收据数量进行调用。
- (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!");
}
有人可以向我解释一下我忽略了什么吗?
答案 0 :(得分:1)
我认为您需要保留按钮。
你发布这个已经有一段时间了,你明白了吗?