Skip to content

Commit

Permalink
Fix crash when dismissing Edit Metadata screen when no left bar butto…
Browse files Browse the repository at this point in the history
…n item present
  • Loading branch information
AndrewBennet committed Oct 3, 2020
1 parent 0dc5481 commit ff3a536
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
15 changes: 9 additions & 6 deletions ReadingList/Storyboards/SearchOnline.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="u1U-1R-a4c">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="u1U-1R-a4c">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15509"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -38,10 +39,7 @@
</tableView>
<toolbarItems>
<barButtonItem title=" Select Many " id="iHn-by-0Xb" customClass="TogglableUIBarButtonItem" customModule="ReadingList_Foundation">
<color key="tintColor" systemColor="systemBlueColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<connections>
<action selector="changeSelectMode:" destination="jSD-sd-NlC" id="Em4-eZ-dPO"/>
</connections>
<color key="tintColor" systemColor="systemBlueColor"/>
</barButtonItem>
<barButtonItem style="plain" systemItem="flexibleSpace" id="XxW-oV-0qE"/>
<barButtonItem enabled="NO" title="Add Books" style="done" id="iO7-e0-41f">
Expand All @@ -68,4 +66,9 @@
<point key="canvasLocation" x="-1458" y="705"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBlueColor">
<color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
7 changes: 6 additions & 1 deletion ReadingList/ViewControllers/Edit/EditBookMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,12 @@ final class EditBookMetadata: FormViewController {
self.dismiss(animated: true)
})
confirmExit.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
confirmExit.popoverPresentationController?.barButtonItem = navigationItem.leftBarButtonItem
if let popover = confirmExit.popoverPresentationController {
guard let barButtonItem = navigationItem.leftBarButtonItem ?? navigationItem.rightBarButtonItem else {
preconditionFailure("Missing navigation bar button item")
}
popover.barButtonItem = barButtonItem
}
present(confirmExit, animated: true, completion: nil)
return
}
Expand Down
7 changes: 6 additions & 1 deletion ReadingList/ViewControllers/Edit/EditBookNotes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ class EditBookNotes: FormViewController {
self.dismiss(animated: true)
})
confirmExit.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
confirmExit.popoverPresentationController?.barButtonItem = navigationItem.leftBarButtonItem
if let popover = confirmExit.popoverPresentationController {
guard let barButtonItem = navigationItem.leftBarButtonItem ?? navigationItem.rightBarButtonItem else {
preconditionFailure("Missing navigation bar button item")
}
popover.barButtonItem = barButtonItem
}
present(confirmExit, animated: true, completion: nil)
return
}
Expand Down
7 changes: 6 additions & 1 deletion ReadingList/ViewControllers/Edit/EditBookReadState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,12 @@ final class EditBookReadState: FormViewController {
self.dismiss(animated: true)
})
confirmExit.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
confirmExit.popoverPresentationController?.barButtonItem = navigationItem.leftBarButtonItem
if let popover = confirmExit.popoverPresentationController {
guard let barButtonItem = navigationItem.leftBarButtonItem ?? navigationItem.rightBarButtonItem else {
preconditionFailure("Missing navigation bar button item")
}
popover.barButtonItem = barButtonItem
}
present(confirmExit, animated: true, completion: nil)
return
}
Expand Down

0 comments on commit ff3a536

Please sign in to comment.