Skip to content

Commit ac63eb1

Browse files
committed
Fix problem rotating device + now the info label is 3 lines long
1 parent 4f7d368 commit ac63eb1

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

Sources/BarcodeScannerController.swift

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ open class BarcodeScannerController: UIViewController {
207207

208208
open override func viewWillAppear(_ animated: Bool) {
209209
super.viewWillAppear(animated)
210-
setupFrame()
211210

212211
headerView.isHidden = !isBeingPresented
213212
}
@@ -216,6 +215,30 @@ open class BarcodeScannerController: UIViewController {
216215
super.viewDidAppear(animated)
217216
animateFocusView()
218217
}
218+
219+
open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
220+
super.viewWillTransition(to: size, with: coordinator)
221+
222+
coordinator.animate(alongsideTransition: { (context) in
223+
self.setupFrame()
224+
}) { (context) in
225+
226+
self.focusView.layer.removeAllAnimations()
227+
228+
UIView.animate(withDuration: 0.3, animations: {
229+
if self.barCodeFocusViewType == .oneDimension {
230+
self.center(subview: self.focusView, inSize: CGSize(width: 280, height: 80))
231+
} else {
232+
self.center(subview: self.focusView, inSize: CGSize(width: 218, height: 150))
233+
}
234+
}, completion: { (finished) in
235+
if finished {
236+
self.animateFocusView()
237+
}
238+
})
239+
240+
}
241+
}
219242

220243
/**
221244
`UIApplicationWillEnterForegroundNotification` action.
@@ -339,7 +362,7 @@ open class BarcodeScannerController: UIViewController {
339362

340363
headerView.isHidden = !isBeingPresented
341364
}
342-
365+
343366
/**
344367
Sets a new size and center aligns subview's position.
345368

0 commit comments

Comments
 (0)