jdg / MBProgressHUD

MBProgressHUD + Customizations
http://www.bukovinski.com/
MIT License
16.01k stars 3.56k forks source link

Unrecognized Selector on label property #408

Closed tbeech closed 8 years ago

tbeech commented 8 years ago

I have the following code in my app:

dispatch_async(dispatch_get_main_queue(), ^{ MBProgressHUD *hud = [MBProgressHUD HUDForView:self.view]; hud.label.text = @"Authenticating"; [hud showAnimated:YES]; });

Which results in the following: *\ Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MBProgressHUD label]: unrecognized selector sent to instance 0x7fa0d33f00b0'

I recently upgraded to v1.0 and previously my code was re-using a single hud and would show/hide and update the label text appropriately. After updating to v1.0 I can't for the life of me get this to work. I've even tried changing the way I was accessing the reusable hud from self.hud to what you see in the above code snippet.

It seems the only way I can get the label text to work is to use the deprecated labelText approach.

matej commented 8 years ago

Are you sure you are linking the new MBProgressHUD.m and that the old one was replaced?

tbeech commented 8 years ago

Yeah, it was really strange. While I was debugging and stepping my code I could see that the label object was there but when the code attempted to reference it I would get the above error. Now with that in mind, since I was using a reusable hud variable (instance object on my class), is the HUD removed as a subview when it's hidden? Not sure if that would make a difference. Also, I had just upgraded to cocoapods 1.0, and was experiencing other issues that seemed related to the upgrade. So perhaps it was still trying to link to the older MBProgressHUD library.

BTW, I've got it all working now, using this code:

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; hud.label.text = @"Authenticating";

So I guess long story short, maybe we close the issue and if I experience it again I will try to come up with a more concrete example.

Thank you,

Travis

ninjitaru commented 8 years ago

Also encountered this problem. It is indeed cause by lib from cocoapods still linked the old MBProgressHUD.m, not knowing why and didn't look into it... Clean the Project, Delete the Pods folder and Podfile.lock file, and do a pod install solve it

db42 commented 8 years ago

Same issue happened with my project. rm -r Pods/MBProgressHUD, clean the project and pod install fixes it.