iOS的内存管理错误 - 消息发送到释放的实例 [英] iOS memory management error - message sent to deallocated instance
问题描述
我创造了许多按钮之前,但由于某些原因,我无法创建一个简单的按钮。
I created many buttons before, but for some reason I'm having trouble creating a simple button.
在我的 viewDidLoad中
方法我创建了一个非常基本的按钮:
In my viewDidLoad
method I created a very basic button:
_button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
_button.frame = CGRectMake(0, 0, 100, 25);
[_button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:_button];
- (void)buttonClicked:(id)sender
{
NSLog(@"%@", sender);
NSLog(@"Download issue");
}
但由于某些原因,当我点击它,我只是得到一个错误
But for some reason when I click on it I'm just getting an error
的 * 的 - [DownloadButtonViewController performSelector:withObject:withObject:]:发送到释放的实例消息0x6ac2af0
* -[DownloadButtonViewController performSelector:withObject:withObject:]: message sent to deallocated instance 0x6ac2af0
我不知道发生了什么事情错了,因为在code是完全一样的,因为每个按钮我之前创建...(可能只是有一个糟糕的一天...)
I have no idea what's going wrong as the code is exactly the same as every button I created before ... (probably just having a bad day ...)
推荐答案
您的视图控制器本身被释放。也许你正在使用ARC,你没有一个强引用您的视图控制器,所以它的创建后立即释放。
Your view controller itself is being deallocated. Maybe you're using ARC and you don't have a strong reference to your view controller, so it's deallocated immediately after creation.
这篇关于iOS的内存管理错误 - 消息发送到释放的实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!