Search code examples
iosobjective-cmemory-leaksuiactionsheetios8.1

UIActionSheet block view controller dealloc


When in my View controller I touch on a button launch this simple code

- (IBAction)tapOnButton:(UIButton *)sender
{
    UIActionSheet *act = [[UIActionSheet alloc] initWithTitle:@"test" delegate:self cancelButtonTitle:@"aa" destructiveButtonTitle:@"bb" otherButtonTitles:@"cc", nil];
    [act showFromRect:CGRectMake(50, 50, 100, 100) inView:self.view animated:YES];
}

-(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0)
    {

    }
}

I get a Actionsheet on screen, tap on any button of the Actionsheet and this closes.

When I run dismiss my viewcontroller is not performed dealloc . If you do not touch the button and do not open the actionsheet the dealloc works .

is a big enough problem. Someone 's going on?

i'm on ios 8.1.3


Solution

  • I am experiencing the same problem using the deprecated UIActionSheet in iOS 8 iPad. Using iPhone (iOS 7 and iOS 8) and iOS 7 iPad, the problem cannot be reproduced.

    The only solution right now that I have tested to be working is to use UIAlertController to present action sheets in iOS 8. If you use UIAlertController, the View Controller gets deallocated correctly.