我在模拟器中使用UIActionSheet或UIAlertController进行以下操作时,发现iOS 8存在内存泄漏问题。由于iOS 8中UIActionSheet使用了UIAlertController,因此这些问题是相关的。
当按钮被按下时,将调用showCameraAction方法。即使我从委托方法中删除了所有内容,仍然会在下面显示的情况下出现泄漏。我是否以某种不应该使用UIActionSheet的方式使用了它?希望能获得任何有助于解决此问题的帮助。相同的代码在iOS 7(模拟器中)中没有泄漏。
抱歉,您需要提供需要翻译的内容。
当按钮被按下时,将调用showCameraAction方法。即使我从委托方法中删除了所有内容,仍然会在下面显示的情况下出现泄漏。我是否以某种不应该使用UIActionSheet的方式使用了它?希望能获得任何有助于解决此问题的帮助。相同的代码在iOS 7(模拟器中)中没有泄漏。
-(IBAction)showCameraAction:(id)sender
{
UIActionSheet* actionSheet = [[UIActionSheet alloc] initWithTitle:@"Photo From:"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Phone", @"Flickr", nil];
[actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];
//also tried just showInView: self.view
}
抱歉,您需要提供需要翻译的内容。
- (void)actionSheet:(UIActionSheet *)actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex {
}
我也尝试了使用UIAlertController,结果相同:
UIAlertController *alertController = [UIAlertController
alertControllerWithTitle:@"Photo From:"
message:@""
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *phoneAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"Phone", @"Phone action")
style:UIAlertActionStyleCancel
handler:^(UIAlertAction *action)
{
NSLog(@"Phone action");
}];
UIAlertAction *flickrAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"Flickr", @"Flickr action")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action)
{
NSLog(@"Flickr action");
}];
[alertController addAction:phoneAction];
[alertController addAction:flickrAction];
[self presentViewController:alertController animated:YES completion:nil];