Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
iOS - Fix the crash of pageview controller (#1292)
Browse files Browse the repository at this point in the history
* LEARNER-7377 * Remove a retainCycle.
Enable animations for the transition of views between the units
Letting the view to complete its lifecycle before performing any extensive UI operations. It was causing the crash because the os wasn’t getting a true picture of view on which it was supposed to perform extensive UI operations.
  • Loading branch information
salman2013 authored Aug 2, 2019
1 parent baa8d02 commit 284d0a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Source/CourseContentPageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public class CourseContentPageViewController : UIPageViewController, UIPageViewC
super.viewWillAppear(animated)
self.navigationController?.setToolbarHidden(false, animated: animated)
courseQuerier.blockWithID(id: blockID).extendLifetimeUntilFirstResult (success:
{ block in
self.environment.analytics.trackScreen(withName: OEXAnalyticsScreenUnitDetail, courseID: self.courseID, value: block.internalName)
{[weak self] block in
self?.environment.analytics.trackScreen(withName: OEXAnalyticsScreenUnitDetail, courseID: self?.courseID ?? "", value: block.internalName)
},
failure: {
Logger.logError("ANALYTICS", "Unable to load block: \($0)")
Expand Down
6 changes: 3 additions & 3 deletions Source/VideoBlockViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,16 @@ class VideoBlockViewController : UIViewController, CourseBlockViewController, St
}

override func viewDidAppear(_ animated : Bool) {

loadVideoIfNecessary()


// There's a weird OS bug where the bottom layout guide doesn't get set properly until
// the layout cycle after viewDidAppear so cause a layout cycle
view.setNeedsUpdateConstraints()
view.updateConstraintsIfNeeded()
view.setNeedsLayout()
view.layoutIfNeeded()
super.viewDidAppear(animated)

loadVideoIfNecessary()

if !(environment.interface?.canDownload() ?? false) {
guard let video = environment.interface?.stateForVideo(withID: blockID, courseID : courseID), video.downloadState == .complete else {
Expand Down

0 comments on commit 284d0a0

Please sign in to comment.