开发者

Why can I not use UIButton to trigger a dismissModalViewController?

开发者 https://www.devze.com 2023-01-07 12:44 出处:网络
I currently have three modalViewControllers and each have their own ways to dismiss. For Two of them, I have to use UILabel and then have using the touchesEnded: method to determine whether the relea

I currently have three modalViewControllers and each have their own ways to dismiss.

For Two of them, I have to use UILabel and then have using the touchesEnded: method to determine whether the release was within the proper area - then call to dismiss the modalViewController.

However, I have one where I can just use a UIButton and it works fine.

I just can't figure out why the heck I can't use a UIButton for all of them. I keep getting the error:

objc[38738]: FREED(id): message release sent to freed object=0x5214f70
Program received signal:  “EXC_BAD_INSTRUCTION”.

I'm assuming it has to do with attempting to access something that has been released (duh) - but I don't have anything occurring other than a -(IBAction)closeWindow:(id)sender {} method that calls:

[self dismissModalViewControllerAnimated:YES];

Any he开发者_如何学编程lp?


You should try running with the zombies instrument to see where you are messaging a freed object. From Xcode just go to Run->Run with Performance Tool->Zombies and that will launch Instruments with the correct setup.

You are probably either releasing (or autoreleasing) an object you shouldn't (because you don't own it) or are failing to retain something that you should. Instruments will help you find out where.


In case people are curious as to how this is working out - I discovered my problem:

I was releasing an object that I had not retained.

Here's my journey to success: http://www.iphonedevsdk.com/forum/iphone-sdk-development/52946-why-can-i-not-use-uibutton-dismiss-modalviewcontroller-consistently.html

0

精彩评论

暂无评论...
验证码 换一张
取 消