Skip to content

Commit

Permalink
Solved didSelectItemAtIndexPath issue #7 (#8)
Browse files Browse the repository at this point in the history
* Solved didSelectItemAtIndexPath issue #7

* remove spaces in lines 121-127 and add space after colon in line 23

* Fixed it more
  • Loading branch information
Maryom authored and serejahh committed Aug 9, 2016
1 parent 9671891 commit 92fa4b2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
13 changes: 2 additions & 11 deletions Example/DisplaySwitcher/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="KUR-je-Sh7">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="KUR-je-Sh7">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
Expand Down Expand Up @@ -82,12 +82,9 @@
<constraint firstItem="H8x-eM-1GS" firstAttribute="top" secondItem="Oi6-wZ-g76" secondAttribute="bottom" id="pPq-nq-yXI"/>
<constraint firstItem="hZF-AP-KvR" firstAttribute="top" secondItem="H8x-eM-1GS" secondAttribute="bottom" id="tgn-L8-bqe"/>
</constraints>
<connections>
<outletCollection property="gestureRecognizers" destination="ucw-iF-foi" appends="YES" id="P8B-l5-rvR"/>
</connections>
</view>
<navigationItem key="navigationItem" title="Friends" id="IHB-pf-cHm">
<barButtonItem key="rightBarButtonItem" width="60" style="plain" id="R8D-p0-NGA">
<barButtonItem key="rightBarButtonItem" width="60" id="R8D-p0-NGA">
<view key="customView" contentMode="scaleToFill" id="70Y-rH-SbY" userLabel="Container View">
<rect key="frame" x="233" y="5" width="71" height="33"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
Expand Down Expand Up @@ -132,12 +129,6 @@
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="22m-rT-erS" userLabel="First Responder" sceneMemberID="firstResponder"/>
<tapGestureRecognizer id="ucw-iF-foi">
<connections>
<action selector="tapRecognized" destination="GxX-QO-EZ4" id="ZEa-X7-XVF"/>
<outlet property="delegate" destination="GxX-QO-EZ4" id="Vwf-80-4Hd"/>
</connections>
</tapGestureRecognizer>
<customObject id="rx3-CL-HDB"/>
</objects>
<point key="canvasLocation" x="656" y="464"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class UserViewController: UIViewController {
@IBOutlet private weak var searchBar: UISearchBar!
@IBOutlet private weak var rotationButton: RotationButton!

private var tap: UITapGestureRecognizer!
private var users = UserDataProvider().generateFakeUsers()
private var searchUsers = [User]()
private var isTransitionAvailable = true
Expand All @@ -31,10 +32,11 @@ class UserViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

tap = UITapGestureRecognizer(target: self, action: #selector(handleTap))

searchUsers = users
rotationButton.selected = true
setupCollectionView()
addGestureRecognizerToNavBar()
}

// MARK: - Private methods
Expand All @@ -43,11 +45,6 @@ class UserViewController: UIViewController {
collectionView.registerNib(UserCollectionViewCell.cellNib, forCellWithReuseIdentifier:UserCollectionViewCell.id)
}

private func addGestureRecognizerToNavBar() {
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(UserViewController.tapRecognized))
navigationController!.navigationBar.addGestureRecognizer(tapRecognizer)
}

// MARK: - Actions
@IBAction func buttonTapped(sender: AnyObject) {
if !isTransitionAvailable {
Expand Down Expand Up @@ -123,5 +120,20 @@ extension UserViewController {
collectionView.reloadData()
}

func collectionView(collectionView: UICollectionView,didSelectItemAtIndexPath indexPath: NSIndexPath) {
print("Hi \(indexPath.row)")
}

func searchBarTextDidBeginEditing(searchBar: UISearchBar) {
view.addGestureRecognizer(tap)
}

func searchBarTextDidEndEditing(searchBar: UISearchBar) {
view.removeGestureRecognizer(tap)
}

func handleTap() {
view.endEditing(true)
}
}

0 comments on commit 92fa4b2

Please sign in to comment.