修复可能的闪退

This commit is contained in:
Fin 2024-12-06 14:15:47 +08:00
parent 11b00b8dea
commit 152c9842f4
4 changed files with 6 additions and 5 deletions

View File

@ -216,10 +216,10 @@ class MessageListViewController: BaseViewController<MessageListViewModel> {
alertController.addAction(copyAction)
alertController.addAction(cancelAction)
if UIDevice.current.userInterfaceIdiom == .pad {
alertController.modalPresentationStyle = .popover
if let cell = self.tableView.cellForRow(at: indexPath) {
alertController.popoverPresentationController?.sourceView = self.tableView
alertController.popoverPresentationController?.sourceRect = cell.frame
alertController.modalPresentationStyle = .popover
}
}

View File

@ -130,10 +130,10 @@ class MessageSettingsViewController: BaseViewController<MessageSettingsViewModel
alertController.addAction(UIAlertAction(title: NSLocalizedString("Cancel"), style: .cancel, handler: nil))
if UIDevice.current.userInterfaceIdiom == .pad {
alertController.modalPresentationStyle = .popover
if let cell = strongSelf.tableView.cellForRow(at: indexPath) {
alertController.popoverPresentationController?.sourceView = strongSelf.tableView
alertController.popoverPresentationController?.sourceRect = cell.frame
alertController.modalPresentationStyle = .popover
}
}
strongSelf.present(alertController, animated: true, completion: nil)

View File

@ -171,10 +171,10 @@ class ServerListViewController: BaseViewController<ServerListViewModel> {
alertController.addAction(UIAlertAction(title: NSLocalizedString("Cancel"), style: .cancel, handler: nil))
if UIDevice.current.userInterfaceIdiom == .pad {
alertController.modalPresentationStyle = .popover
if let cell = self.tableView.cellForRow(at: indexPath) {
alertController.popoverPresentationController?.sourceView = self.tableView
alertController.popoverPresentationController?.sourceRect = cell.frame
alertController.modalPresentationStyle = .popover
}
}
self.navigationController?.present(alertController, animated: true, completion: nil)

View File

@ -15,7 +15,8 @@ class IconProcessor: NotificationContentProcessor {
let userInfo = bestAttemptContent.userInfo
guard let imageUrl = userInfo["icon"] as? String,
let imageFileUrl = await ImageDownloader.downloadImage(imageUrl)
let imageFileUrl = await ImageDownloader.downloadImage(imageUrl),
let imageData = NSData(contentsOfFile: imageFileUrl)
else {
return bestAttemptContent
}
@ -23,7 +24,7 @@ class IconProcessor: NotificationContentProcessor {
var personNameComponents = PersonNameComponents()
personNameComponents.nickname = bestAttemptContent.title
let avatar = INImage(imageData: NSData(contentsOfFile: imageFileUrl)! as Data)
let avatar = INImage(imageData: imageData as Data)
let senderPerson = INPerson(
personHandle: INPersonHandle(value: "", type: .unknown),
nameComponents: personNameComponents,