Skip to content

Commit

Permalink
fix crash when try to remove observer.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Barreto committed Jan 29, 2016
1 parent 17f2e05 commit 6e4a319
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
12 changes: 12 additions & 0 deletions Example/Example/Base.lproj/Storyboard.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,20 @@
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="kmN-fg-NDL">
<rect key="frame" x="21" y="82" width="46" height="34"/>
<state key="normal" title="Close">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="closeTapped:" destination="uba-Iz-2L2" eventType="touchUpInside" id="B1v-kE-kC0"/>
<action selector="reloadTapped:" destination="uba-Iz-2L2" eventType="touchUpInside" id="73B-ps-jro"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="0.027450980390000001" green="0.72549019609999998" blue="0.60784313729999995" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="kmN-fg-NDL" firstAttribute="top" secondItem="Emc-3r-MJi" secondAttribute="bottom" constant="62" id="7Rq-MO-b4m"/>
<constraint firstItem="cZN-qT-VUq" firstAttribute="leading" secondItem="Mqm-sG-Qyv" secondAttribute="leadingMargin" id="9eC-5j-2zk"/>
<constraint firstAttribute="centerX" secondItem="cZN-qT-VUq" secondAttribute="centerX" id="AYy-gw-Ryh"/>
<constraint firstItem="NbE-e0-l2n" firstAttribute="top" secondItem="qkQ-UG-MKG" secondAttribute="bottom" id="K6Q-s5-nzV"/>
Expand All @@ -107,6 +118,7 @@
<constraint firstItem="jSE-G2-qe6" firstAttribute="trailing" secondItem="Mqm-sG-Qyv" secondAttribute="trailingMargin" id="hbB-fi-M5S"/>
<constraint firstItem="qkQ-UG-MKG" firstAttribute="top" secondItem="Emc-3r-MJi" secondAttribute="bottom" constant="101" id="nJw-ag-ddh"/>
<constraint firstAttribute="trailing" secondItem="qkQ-UG-MKG" secondAttribute="trailing" id="pTb-BC-Duc"/>
<constraint firstItem="kmN-fg-NDL" firstAttribute="leading" secondItem="Mqm-sG-Qyv" secondAttribute="leadingMargin" constant="1" id="sXd-CC-BrV"/>
</constraints>
<variation key="default">
<mask key="constraints">
Expand Down
5 changes: 5 additions & 0 deletions Example/Example/ReloadExampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ class ReloadExampleViewController: UIViewController {
}
}


@IBAction func closeTapped(sender: UIButton) {
dismissViewControllerAnimated(true, completion: nil)
}

func updateTitle(pagerTabStripViewController: PagerTabStripViewController) {
func stringFromBool(bool: Bool) -> String {
return bool ? "YES" : "NO"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<a href="https://raw.githubusercontent.com/xmartlabs/XLPagerTabStrip/master/LICENSE"><img src="http://img.shields.io/badge/license-MIT-blue.svg?style=flat" alt="License: MIT" /></a>
</p>

Made with ❤️ by [Xmartlabs](http://xmartlabs.com).
Made with ❤️ by [Xmartlabs](http://xmartlabs.com).

Android [PagerTabStrip](http://developer.android.com/reference/android/support/v4/view/PagerTabStrip.html) for iOS!

Expand Down Expand Up @@ -201,7 +201,7 @@ We may need to update the indicator cell when the displayed view controller chan
public var changeCurrentIndex: ((oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, animated: Bool) -> Void)?
public var changeCurrentIndexProgressive: ((oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void)?

Let's see am example:
Let's see an example:

```swift
changeCurrentIndexProgressive = { (oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in
Expand Down
10 changes: 5 additions & 5 deletions Sources/TwitterPagerTabStripViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public class TwitterPagerTabStripViewController: PagerTabStripViewController, Pa

public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
pagerBehaviour = .Common(skipIntermediateViewControllers: true)
pagerBehaviour = .Progressive(skipIntermediateViewControllers: true, elasticIndicatorLimit: true)
delegate = self
datasource = self
}

required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
pagerBehaviour = PagerTabStripBehaviour.Common(skipIntermediateViewControllers: true)
pagerBehaviour = .Progressive(skipIntermediateViewControllers: true, elasticIndicatorLimit: true)
delegate = self
datasource = self
}
Expand All @@ -73,7 +73,7 @@ public class TwitterPagerTabStripViewController: PagerTabStripViewController, Pa
titleView.addSubview(pageControl)
reloadNavigationViewItems()
}

public override func reloadPagerTabStripView() {
super.reloadPagerTabStripView()
guard isViewLoaded() else { return }
Expand Down Expand Up @@ -123,7 +123,7 @@ public class TwitterPagerTabStripViewController: PagerTabStripViewController, Pa
}

deinit {
titleView.removeObserver(self, forKeyPath: "frame")
NSNotificationCenter.defaultCenter().removeObserver(self)
}

public override func viewDidLayoutSubviews() {
Expand All @@ -133,7 +133,7 @@ public class TwitterPagerTabStripViewController: PagerTabStripViewController, Pa

// MARK: - Helpers

private lazy var titleView: UIView = { [unowned self] in
private lazy var titleView: UIView = {
let navigationView = UIView()
navigationView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
return navigationView
Expand Down

0 comments on commit 6e4a319

Please sign in to comment.