UIAlertView fails to show and results in “EXC_BAD_ACCESS” error

前端 未结 6 2050
一向
一向 2021-01-21 01:05

A method is called when a return button on the keyboard is pressed. After calling another method which returns an integer a message is created based on that integer. The message

6条回答
  •  情话喂你
    2021-01-21 01:40

    I had the same problem here with a UIAlertView, in my case, I had another class implementing the alert, and, from another one I was calling a static method. Like the following:

    ClassA
    
    ...
    
    doSomething {
     ... some stuff ...
    
     [MyAlertView showAlert];
    
     ... some other stuff...
    
    }
    

    What I suspect is that, as the alertview is shown asynchronously when I clicked the button the object was already released.

    To verify that, I changed the code to instantiate the alert and not release it. And everythong worked.

    My final solution was to declare a variable in the parent view, and deallocate it with the other variables when the view is deallocated.

提交回复
热议问题