gpt4 book ai didi

iphone - UIViewController中的"[CALayer release]: message sent to deallocated instance"

转载 作者:行者123 更新时间:2023-12-03 20:26:02 26 4
gpt4 key购买 nike

我在 UIViewController 中有一个 MapView。当我尝试在 viewDidUnload 之后加载 View 时,它崩溃并显示以下消息:

-[CALayer release]:消息发送到已释放的实例 0x29aea0

我认为我在 viewDidUnload 中做了所有我应该做的必要的事情:

- (void)viewDidUnload {

[super viewDidUnload];

locationManager.delegate = nil;
[locationManager release];
locationManager = nil;

mapView.delegate = nil;
[mapView release];
mapView = nil;
}

我的 MapView 位于 xib 文件中配置的 UIView 中。我的 VC 从未被释放。

我已经在谷歌上搜索了一段时间,但找不到答案。

编辑

 - (void)viewDidLoad {

[super viewDidLoad];

locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager startUpdatingLocation];

[label setFont:[UIFont fontWithName:@"Sansation" size:28]];
[label setShadowOffset:CGSizeMake(0, 1)];
[label setShadowColor:[UIColor grayColor]];
self.navigationItem.titleView = labelView;
[label release];
[labelView release];

UIBarButtonItem *checkInButton = [[UIBarButtonItem alloc] initWithTitle:@"Checka In" style:UIBarButtonItemStylePlain target:self action:@selector(checkIn)];
[[self navigationItem] setRightBarButtonItem:checkInButton];
[checkInButton release];

UIBarButtonItem *clueListButton = [[UIBarButtonItem alloc] initWithTitle:@"Ledtrådar" style:UIBarButtonItemStylePlain target:self action:@selector(cluesDown)];
[[self navigationItem] setLeftBarButtonItem:clueListButton];
[clueListButton release];

UINavigationBar *bar = [self.navigationController navigationBar];
[bar setTintColor:[UIColor colorWithRed:0.06 green:0.58 blue:0.88 alpha:1]];
}

“labelView”和“label”是IBOutlet。

最佳答案

由于您在 viewDidLoad 方法中既没有分配也没有保留 labellabelView,所以您不能在这里释放它们(您过度释放了它们) .

关于iphone - UIViewController中的"[CALayer release]: message sent to deallocated instance",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5855881/

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