Note that there are some explanatory texts on larger screens.

plurals
  1. POUIButton action doesn't work after some time (probably after some garbage collection)
    primarykey
    data
    text
    <p>I have a UIView with around 60 buttons who call the same method. When clicking the buttons, I open different images by this method - I use button tags to know which button was called and which image to display. Think about it like a gallery.</p> <p>As the drawing of the buttons was difficult, I used the Interface Builder for that and created a XIB with that UIView. I simply dragged the buttons at the correct spots and connected them to my method at event TouchUpInside. I used this to add the view to my main view:</p> <pre><code>NSArray *xibContents = [[NSBundle mainBundle] loadNibNamed:@"Tour" owner:self options:nil]; UIView *tour = [xibContents lastObject]; [self.view addSubview:tour]; </code></pre> <p>So far so good, that works well at first glance. Unfortunately, there is some issue when the app has been used for some time. The buttons still highlight (so they are still here!) but there is no action called anymore. There just the highlight but no action.</p> <p>I don't know why, but somehow the garbage collector seems to destroy the UIButton target. Why? How can I fix that?</p> <p>Please note I haven't declared the buttons programmatically. I thought placing them in the IB would be enough.</p> <p>Also I couldn't find a connection between memory warnings and the destruction of the UIButton targets. Memory warnings do appear in my app, but most of the time the buttons still work then.</p> <p>But it has to be a garbage collector because the bug comes up totally randomly. There is no way to reproduce this error, sometimes it happens after 5 clicks, sometimes after 10 minutes spending in my app.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload