Skip to content

Commit 26ca271

Browse files
committed
Part 4
1 parent caf4d07 commit 26ca271

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

MusicPlayer/Base.lproj/Main.storyboard

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,28 @@
1919
<tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="ODz-Kv-YZf">
2020
<rect key="frame" x="0.0" y="28" width="600" height="572"/>
2121
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
22+
<prototypes>
23+
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="SearchResultCell" textLabel="FLS-n6-DaU" detailTextLabel="Jvv-sN-yxy" style="IBUITableViewCellStyleSubtitle" id="aTo-eA-rHa">
24+
<autoresizingMask key="autoresizingMask"/>
25+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="aTo-eA-rHa" id="TeG-K4-hoS">
26+
<autoresizingMask key="autoresizingMask"/>
27+
<subviews>
28+
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="FLS-n6-DaU">
29+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
30+
<fontDescription key="fontDescription" type="system" pointSize="16"/>
31+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
32+
<nil key="highlightedColor"/>
33+
</label>
34+
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Subtitle" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Jvv-sN-yxy">
35+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
36+
<fontDescription key="fontDescription" type="system" pointSize="11"/>
37+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
38+
<nil key="highlightedColor"/>
39+
</label>
40+
</subviews>
41+
</tableViewCellContentView>
42+
</tableViewCell>
43+
</prototypes>
2244
<connections>
2345
<outlet property="dataSource" destination="vXZ-lx-hvc" id="7cL-cq-1uJ"/>
2446
<outlet property="delegate" destination="vXZ-lx-hvc" id="Xh9-VM-kGO"/>

MusicPlayer/SearchResultsViewController.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa
1313
@IBOutlet var appsTableView : UITableView?
1414
var tableData = []
1515
var api = APIController()
16+
let kCellIdentifier: String = "SearchResultCell"
1617

1718
override func viewDidLoad() {
1819
super.viewDidLoad()
@@ -30,7 +31,7 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa
3031
}
3132

3233
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
33-
let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "MyTestCell")
34+
let cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier) as UITableViewCell
3435

3536
let rowData: NSDictionary = self.tableData[indexPath.row] as NSDictionary
3637

@@ -59,6 +60,20 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa
5960
self.appsTableView!.reloadData()
6061
})
6162
}
63+
64+
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
65+
// Get the row data for the selected row
66+
var rowData: NSDictionary = self.tableData[indexPath.row] as NSDictionary
67+
68+
var name: String = rowData["trackName"] as String
69+
var formattedPrice: String = rowData["formattedPrice"] as String
70+
71+
var alert: UIAlertView = UIAlertView()
72+
alert.title = name
73+
alert.message = formattedPrice
74+
alert.addButtonWithTitle("Ok")
75+
alert.show()
76+
}
6277

6378
}
6479

0 commit comments

Comments
 (0)