0

我尝试了导致 iOS8.4 SDK 内存泄漏的 UIAlertView 和 UIActionSheet 对象。来自支持最低 iOS8 操作系统的 iOS8 的新对象(例如 UIAlertController)。如何在 iOS8 和之前的版本中处理这种泄漏?

导致泄漏的示例代码;

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" 
                                                message:@"" 
                                                delegate:self 
                                                cancelButtonTitle:@"OK" 
                                                otherButtonTitles:nil];
[alert show];
4

1 回答 1

0

我建议检查课程的可用性。例如,如果要检查是否使用UIAlertControlleror UIAlertViewthen:

if ([UIAlertController class]) {
   // use UIAlertController

} else {
  // use UIAlertView

}
于 2015-07-30T08:18:12.113 回答