Skip to content

Commit 1c2ed3a

Browse files
author
Steve Trease
committed
Build 279.
After much messing have fixed the randomly resizing, faulty cell auto layout height. Finally.
1 parent 6e95945 commit 1c2ed3a

File tree

6 files changed

+54
-37
lines changed

6 files changed

+54
-37
lines changed

Swift Push 3/AppDelegate.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2323
var item = NotificationData()
2424
// item.alert = "Swift Push (\(versionNumber)) starting on " + UIDevice.currentDevice().name
2525
item.alert = "Swift Push starting on " + UIDevice.currentDevice().name
26-
26+
notifications.insert(item, atIndex: 0)
27+
item = NotificationData()
28+
// item.alert = "Swift Push (\(versionNumber)) starting on " + UIDevice.currentDevice().name
29+
item.alert = "Swift Push starting on " + UIDevice.currentDevice().name
30+
notifications.insert(item, atIndex: 0)
31+
item = NotificationData()
32+
// item.alert = "Swift Push (\(versionNumber)) starting on " + UIDevice.currentDevice().name
33+
item.alert = "Swift Push starting on " + UIDevice.currentDevice().name
2734
notifications.insert(item, atIndex: 0)
2835

2936
switch (application.applicationState) {
@@ -37,8 +44,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3744
println ("didFinishLaunchingWithOptions - unknown application state")
3845
}
3946

40-
var types: UIUserNotificationType = UIUserNotificationType.Badge |
47+
var types: UIUserNotificationType =
4148
UIUserNotificationType.Alert |
49+
UIUserNotificationType.Badge |
4250
UIUserNotificationType.Sound
4351

4452
var settings: UIUserNotificationSettings = UIUserNotificationSettings( forTypes: types, categories: nil )
@@ -57,7 +65,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
5765

5866

5967
func application(application: UIApplication!, didRegisterForRemoteNotificationsWithDeviceToken deviceToken:NSData!) {
60-
6168
let existingToken: AnyObject? = NSUserDefaults.standardUserDefaults().objectForKey("deviceToken")
6269

6370
println("device token is " + deviceToken.description)
@@ -86,8 +93,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
8693

8794

8895
func application(application: UIApplication!, didReceiveRemoteNotification userInfo:NSDictionary!, fetchCompletionHandler completionHandler: ((UIBackgroundFetchResult) -> Void)!) {
89-
90-
println()
9196
switch (application.applicationState) {
9297
case UIApplicationState.Active:
9398
println ("notification received by AppDeligate whilst active")

Swift Push 3/Base.lproj/Main.storyboard

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6751" systemVersion="14D113c" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="NEu-qu-DLA">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6751" systemVersion="14D127a" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="NEu-qu-DLA">
33
<dependencies>
44
<deployment version="2048" identifier="iOS"/>
55
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6736"/>
@@ -18,15 +18,29 @@
1818
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
1919
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no"/>
2020
<connections>
21-
<outlet property="delegate" destination="Ciy-dE-pCt" id="ved-Mb-i1U"/>
21+
<outlet property="delegate" destination="Ciy-dE-pCt" id="Kd5-bn-Rn3"/>
2222
</connections>
2323
</searchBar>
2424
<prototypes>
25-
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="ReuseCell" id="dCV-Qf-4PF">
25+
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="ReuseCell" textLabel="zI5-fr-ipi" detailTextLabel="3LV-oS-vV3" style="IBUITableViewCellStyleSubtitle" id="dCV-Qf-4PF">
2626
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
2727
<autoresizingMask key="autoresizingMask"/>
2828
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="dCV-Qf-4PF" id="nNg-o2-Q2w">
2929
<autoresizingMask key="autoresizingMask"/>
30+
<subviews>
31+
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="zI5-fr-ipi">
32+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
33+
<fontDescription key="fontDescription" type="system" pointSize="16"/>
34+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
35+
<nil key="highlightedColor"/>
36+
</label>
37+
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Subtitle" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="3LV-oS-vV3">
38+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
39+
<fontDescription key="fontDescription" type="system" pointSize="11"/>
40+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
41+
<nil key="highlightedColor"/>
42+
</label>
43+
</subviews>
3044
</tableViewCellContentView>
3145
</tableViewCell>
3246
</prototypes>

Swift Push 3/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>252</string>
22+
<string>279</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
2525
<key>UIBackgroundModes</key>

Swift Push 3/NotificationsTableViewController.swift

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,34 @@
88

99
import UIKit
1010

11-
class NotificationsTableViewController: UITableViewController, UISearchBarDelegate {
11+
class NotificationsTableViewController: UITableViewController, UISearchBarDelegate, UITableViewDataSource {
1212

1313
var filteredNotifications = [NotificationData]()
1414

1515
func filterContentForSearchText(searchText: String) {
1616
// Filter the array using the filter method
17-
self.filteredNotifications = notifications.filter({( notification: NotificationData) -> Bool in
17+
filteredNotifications = notifications.filter({( notification: NotificationData) -> Bool in
1818
let stringMatch = notification.alert.lowercaseString.rangeOfString(searchText.lowercaseString)
1919
return (stringMatch != nil)
2020
})
2121
}
2222

2323
func searchDisplayController(controller: UISearchDisplayController!, shouldReloadTableForSearchString searchString: String!) -> Bool {
24-
self.filterContentForSearchText(searchString)
24+
filterContentForSearchText(searchString)
25+
println("searchDisplayController:")
2526
return true
2627
}
2728

2829
func searchDisplayController(controller: UISearchDisplayController!, shouldReloadTableForSearchScope searchOption: Int) -> Bool {
29-
self.filterContentForSearchText(self.searchDisplayController!.searchBar.text)
30+
filterContentForSearchText(self.searchDisplayController!.searchBar.text)
31+
println("searchDisplayController")
3032
return true
3133
}
3234

3335
override func viewDidLoad() {
3436
super.viewDidLoad()
3537
println("viewDidLoad")
36-
38+
3739
let notificationCenter = NSNotificationCenter.defaultCenter()
3840
let mainQueue = NSOperationQueue.mainQueue()
3941

@@ -43,59 +45,54 @@ class NotificationsTableViewController: UITableViewController, UISearchBarDelega
4345

4446
self.tableView.estimatedRowHeight = 44.0
4547
self.tableView.rowHeight = UITableViewAutomaticDimension
46-
4748
}
4849

4950
override func didReceiveMemoryWarning() {
5051
super.didReceiveMemoryWarning()
52+
println("didReceiveMemoryWarning")
5153
// Dispose of any resources that can be recreated.
5254
}
5355

5456
// MARK: - Table view data source
5557
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
56-
// #warning Potentially incomplete method implementation.
57-
// Return the number of sections.
5858
return 1
5959
}
6060

61-
// Fix suggested at http://www.appcoda.com/self-sizing-cells/
62-
//
63-
override func viewDidAppear(animated: Bool) {
64-
tableView.reloadData()
65-
}
66-
61+
// override func viewDidAppear(animated: Bool) {
62+
// self.tableView.estimatedRowHeight = 44.0
63+
// self.tableView.rowHeight = UITableViewAutomaticDimension
64+
// tableView.reloadData()
65+
//}
66+
6767
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
68-
// #warning Incomplete method implementation.
69-
// Return the number of rows in the section.
7068
if tableView == self.searchDisplayController!.searchResultsTableView {
71-
return self.filteredNotifications.count
69+
return filteredNotifications.count
7270
} else {
7371
return notifications.count
7472
}
7573
}
7674

7775
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
78-
79-
// println("cellForRowAtIndexPath")
80-
let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "ReuseCell")
81-
76+
println("cellForRowAtIndexPath ", indexPath.row)
77+
8278
var notification : NotificationData
83-
8479
if tableView == self.searchDisplayController!.searchResultsTableView {
8580
notification = filteredNotifications[indexPath.row]
8681
} else {
8782
notification = notifications[indexPath.row]
8883
}
8984

90-
cell.layer.cornerRadius = 5.0
85+
let cell: UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier("ReuseCell", forIndexPath: indexPath) as UITableViewCell
86+
87+
// let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "ReuseCell")
88+
89+
cell.layer.cornerRadius = 10.0
9190
cell.layer.masksToBounds = true
9291
cell.textLabel?.numberOfLines = 0
9392
cell.detailTextLabel?.numberOfLines = 0
9493

95-
let timeStamp = NSDateFormatter.localizedStringFromDate(notification.timeStamp, dateStyle: .MediumStyle, timeStyle: .ShortStyle)
96-
9794
cell.textLabel?.text = notification.alert as String
98-
cell.detailTextLabel?.text = timeStamp
95+
cell.detailTextLabel?.text = NSDateFormatter.localizedStringFromDate(notification.timeStamp, dateStyle: .MediumStyle, timeStyle: .ShortStyle)
9996

10097
if (indexPath.row % 2 == 0 ) {
10198
cell.backgroundColor = UIColor(white: 0.95, alpha: 1.0)
@@ -105,7 +102,7 @@ class NotificationsTableViewController: UITableViewController, UISearchBarDelega
105102

106103
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
107104
tableView.deselectRowAtIndexPath(indexPath, animated: true)
108-
println("selecting row: \(indexPath.row)")
105+
println("selecting row: ", indexPath.row)
109106
}
110107

111108
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath)
@@ -116,6 +113,7 @@ class NotificationsTableViewController: UITableViewController, UISearchBarDelega
116113
}
117114

118115
func onContentSizeChange(notification: NSNotification) {
116+
println("onContentSizeChange")
119117
tableView.reloadData()
120118
}
121119

Swift Push 3/Settings.bundle/Root.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<array>
77
<dict>
88
<key>DefaultValue</key>
9-
<string>252</string>
9+
<string>279</string>
1010
<key>Key</key>
1111
<string>CurrentBuildNumber</string>
1212
<key>Title</key>

0 commit comments

Comments
 (0)