From 330cc54566b4ce0e13be734d4a551a8e5bfde40f Mon Sep 17 00:00:00 2001 From: ylzheng Date: Sun, 25 Oct 2015 18:35:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A2=E7=B4=A2=E5=8F=91=E7=8E=B0=EF=BC=8C?= =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=AD=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- librx.xcodeproj/project.pbxproj | 12 ++ librx/Base.lproj/Main.storyboard | 128 ++++++++++++++++------ librx/DashViewController.swift | 11 +- librx/ExploreCell.swift | 3 +- librx/ExploreCollectionReusableView.swift | 19 +++- librx/ExploreSource.swift | 33 ++++++ librx/ExploreTableCell.swift | 19 ++++ librx/ExploreTableViewController.swift | 84 ++++++++++++++ librx/JsonPaser.swift | 7 +- librx/LibrxService.swift | 54 ++++++--- librx/PostsLoader.swift | 26 ++++- librx/Profile.swift | 6 +- librx/ProfileViewController.swift | 8 +- librx/SettingTableViewController.swift | 2 +- librx/StorysTableViewController.swift | 31 +----- librx/WebViewController.swift | 1 - 16 files changed, 352 insertions(+), 92 deletions(-) create mode 100644 librx/ExploreSource.swift create mode 100644 librx/ExploreTableCell.swift create mode 100644 librx/ExploreTableViewController.swift diff --git a/librx.xcodeproj/project.pbxproj b/librx.xcodeproj/project.pbxproj index cdf04e7..3bbe1dc 100644 --- a/librx.xcodeproj/project.pbxproj +++ b/librx.xcodeproj/project.pbxproj @@ -60,6 +60,9 @@ 45CF5AD11B8DFD64001E5CFC /* LoginService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45CF5AD01B8DFD63001E5CFC /* LoginService.swift */; }; 45CF60481B67C3D900CA7F06 /* StorysTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45CF60471B67C3D900CA7F06 /* StorysTableViewController.swift */; }; 45D09EB01BDBD375006F91C2 /* LineChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45D09EAF1BDBD375006F91C2 /* LineChart.swift */; }; + 45D4B1C91BDCC45900E3FA32 /* ExploreTableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45D4B1C81BDCC45900E3FA32 /* ExploreTableCell.swift */; }; + 45D4B1CB1BDCC55600E3FA32 /* ExploreTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45D4B1CA1BDCC55600E3FA32 /* ExploreTableViewController.swift */; }; + 45D4B1CD1BDCC76600E3FA32 /* ExploreSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45D4B1CC1BDCC76600E3FA32 /* ExploreSource.swift */; }; 45D77BB81BAD14C300618CAC /* RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45D77BB71BAD14C300618CAC /* RootViewController.swift */; }; 45D8E71D1B71CA6E00A33659 /* Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45D8E71C1B71CA6E00A33659 /* Extension.swift */; }; 45D8E7241B71E3BA00A33659 /* ProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45D8E7231B71E3BA00A33659 /* ProfileViewController.swift */; }; @@ -182,6 +185,9 @@ 45CF5AD01B8DFD63001E5CFC /* LoginService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginService.swift; sourceTree = ""; }; 45CF60471B67C3D900CA7F06 /* StorysTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorysTableViewController.swift; sourceTree = ""; }; 45D09EAF1BDBD375006F91C2 /* LineChart.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LineChart.swift; sourceTree = ""; }; + 45D4B1C81BDCC45900E3FA32 /* ExploreTableCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExploreTableCell.swift; sourceTree = ""; }; + 45D4B1CA1BDCC55600E3FA32 /* ExploreTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExploreTableViewController.swift; sourceTree = ""; }; + 45D4B1CC1BDCC76600E3FA32 /* ExploreSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExploreSource.swift; sourceTree = ""; }; 45D77BB71BAD14C300618CAC /* RootViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RootViewController.swift; sourceTree = ""; }; 45D8E71C1B71CA6E00A33659 /* Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Extension.swift; sourceTree = ""; }; 45D8E7231B71E3BA00A33659 /* ProfileViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileViewController.swift; sourceTree = ""; }; @@ -426,6 +432,7 @@ 45517B131BCBE743004C6D10 /* ContainerViewController.swift */, 45517B151BCCB73D004C6D10 /* GraphsUIViewController.swift */, 4544DAD51BCD4358002B6666 /* SettingTableViewController.swift */, + 45D4B1CA1BDCC55600E3FA32 /* ExploreTableViewController.swift */, ); name = controllers; sourceTree = ""; @@ -439,6 +446,7 @@ 45681F331B7F7C8A00D1E096 /* User.swift */, 450F9B901BAB09B800D4EF3B /* Explore.swift */, 45A50FBF1BC96608009897FF /* Profile.swift */, + 45D4B1CC1BDCC76600E3FA32 /* ExploreSource.swift */, ); name = models; sourceTree = ""; @@ -462,6 +470,7 @@ 451281D31B6F926500C59C6B /* CustomTableCell.swift */, 456F1A1D1B6FD4D0007F9ACF /* MenuTableViewCell.swift */, 45E713731B9F39A7002FFCBB /* ExploreCell.swift */, + 45D4B1C81BDCC45900E3FA32 /* ExploreTableCell.swift */, ); name = cells; sourceTree = ""; @@ -744,6 +753,7 @@ 455B954E1B94A3A300001F9F /* CreatePostViewController.swift in Sources */, 45B11CCD1B6FC029008D6049 /* UIView_Borders.swift in Sources */, 45C24EF91BAD894D00BACB81 /* RGPageViewController.swift in Sources */, + 45D4B1C91BDCC45900E3FA32 /* ExploreTableCell.swift in Sources */, 456F1A1E1B6FD4D0007F9ACF /* MenuTableViewCell.swift in Sources */, 456F1A171B6FD3D6007F9ACF /* MenuTableViewController.swift in Sources */, 45AD0E2E1B857EA600283FCC /* WebViewController.swift in Sources */, @@ -760,6 +770,8 @@ 45C24EFB1BAD899D00BACB81 /* DashViewController.swift in Sources */, 45681F2E1B7F781E00D1E096 /* Replyable.swift in Sources */, 45F6B0B51B95CCA200BDF464 /* BaiscTabBarController.swift in Sources */, + 45D4B1CB1BDCC55600E3FA32 /* ExploreTableViewController.swift in Sources */, + 45D4B1CD1BDCC76600E3FA32 /* ExploreSource.swift in Sources */, 45C24EFE1BADA48E00BACB81 /* UIColorExtension.swift in Sources */, 45D09EB01BDBD375006F91C2 /* LineChart.swift in Sources */, 45CF60481B67C3D900CA7F06 /* StorysTableViewController.swift in Sources */, diff --git a/librx/Base.lproj/Main.storyboard b/librx/Base.lproj/Main.storyboard index 2e31634..14d553c 100644 --- a/librx/Base.lproj/Main.storyboard +++ b/librx/Base.lproj/Main.storyboard @@ -174,9 +174,10 @@ - + + @@ -631,6 +632,7 @@ + @@ -816,44 +818,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -909,6 +881,7 @@ + @@ -939,6 +912,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1456,7 +1517,6 @@ - @@ -1465,7 +1525,7 @@ - + diff --git a/librx/DashViewController.swift b/librx/DashViewController.swift index ebbddb4..7690d25 100644 --- a/librx/DashViewController.swift +++ b/librx/DashViewController.swift @@ -15,7 +15,7 @@ class DashViewController: RGPageViewController, RGPageViewControllerDataSource, private var loginStateChange: LoginStateHandler? - var menu: NSArray = ["热门", "最新", "信息流"] + var menu: NSArray = ["信息流", "最新", "热门"] var storysViewController1: StorysTableViewController! var storysViewController2: StorysTableViewController! var storysViewController3: StorysTableViewController! @@ -43,12 +43,15 @@ class DashViewController: RGPageViewController, RGPageViewControllerDataSource, self.storysViewController1 = storyboard.instantiateViewControllerWithIdentifier("StoriesTableViewController") as! StorysTableViewController self.storysViewController1.postSection = .Default + self.storysViewController1.isInlineOfContainer = false self.storysViewController2 = storyboard.instantiateViewControllerWithIdentifier("StoriesTableViewController") as! StorysTableViewController self.storysViewController2.postSection = .RecentTimeLine + self.storysViewController2.isInlineOfContainer = false self.storysViewController3 = storyboard.instantiateViewControllerWithIdentifier("StoriesTableViewController") as! StorysTableViewController self.storysViewController3.postSection = .HotTimeLine + self.storysViewController3.isInlineOfContainer = false } @@ -74,10 +77,10 @@ class DashViewController: RGPageViewController, RGPageViewControllerDataSource, func viewControllerForPageAtIndex(pageViewController: RGPageViewController, index: Int) -> UIViewController? { switch index { - case 0: return self.storysViewController1 + case 0: return self.storysViewController3 case 1: return self.storysViewController2 - case 2: return self.storysViewController3 - default: return storysViewController1 + case 2: return self.storysViewController1 + default: return storysViewController3 } diff --git a/librx/ExploreCell.swift b/librx/ExploreCell.swift index 4a81a05..b0db06d 100644 --- a/librx/ExploreCell.swift +++ b/librx/ExploreCell.swift @@ -12,6 +12,5 @@ class ExploreCell: UICollectionViewCell { @IBOutlet weak var nameLabel: UILabel! @IBOutlet weak var iconImage: UIImageView! - - + } diff --git a/librx/ExploreCollectionReusableView.swift b/librx/ExploreCollectionReusableView.swift index b39537a..534d9fe 100644 --- a/librx/ExploreCollectionReusableView.swift +++ b/librx/ExploreCollectionReusableView.swift @@ -47,7 +47,6 @@ class ExploreCollectionViewController: UICollectionViewController, UICollectionV override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) - LibrxService.loadExplore { (explores) -> () in self.explores = explores self.collectionView?.reloadData() @@ -99,4 +98,22 @@ class ExploreCollectionViewController: UICollectionViewController, UICollectionV dismissViewControllerAnimated(true, completion: nil) } + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + + if segue.identifier == "showExploreSegue" { + + if let indexPaths = self.collectionView?.indexPathsForSelectedItems() { + + let selectedExplore = self.explores[indexPaths[0].row] + let destinationController = segue.destinationViewController as! ExploreTableViewController + destinationController.title = selectedExplore.name + destinationController.dataUrl = selectedExplore.resourceUrl + + } + + + } + + } + } diff --git a/librx/ExploreSource.swift b/librx/ExploreSource.swift new file mode 100644 index 0000000..ab52cb4 --- /dev/null +++ b/librx/ExploreSource.swift @@ -0,0 +1,33 @@ +// +// ExploreSource.swift +// librx +// +// Created by Yunlong Zheng on 15/10/25. +// Copyright © 2015年 librx. All rights reserved. +// + +import Foundation + +class ExploreSource{ + + + let id: Int + let title: String + let img: String + let description: String + let source_type: String + + init(id: Int, + title: String, + img: String, + description: String, + source_type: String){ + self.id = id + self.title = title + self.img = img + self.description = description + self.source_type = source_type + + } + +} \ No newline at end of file diff --git a/librx/ExploreTableCell.swift b/librx/ExploreTableCell.swift new file mode 100644 index 0000000..0192b7e --- /dev/null +++ b/librx/ExploreTableCell.swift @@ -0,0 +1,19 @@ +// +// ExploreTableCell.swift +// librx +// +// Created by Yunlong Zheng on 15/10/25. +// Copyright © 2015年 librx. All rights reserved. +// + +import UIKit + + +class ExploreTableCell: UITableViewCell { + + + @IBOutlet weak var sourceImg: UIImageView! + @IBOutlet weak var sourceTitle: UILabel! + @IBOutlet weak var descriptionLabel: UILabel! + +} \ No newline at end of file diff --git a/librx/ExploreTableViewController.swift b/librx/ExploreTableViewController.swift new file mode 100644 index 0000000..341dd79 --- /dev/null +++ b/librx/ExploreTableViewController.swift @@ -0,0 +1,84 @@ +// ExploreTableViewController.swift +// +// librx +// +// Created by Yunlong Zheng on 15/10/25. +// Copyright © 2015年 librx. All rights reserved. +// + +import UIKit + +class ExploreTableViewController: UITableViewController { + + private var postsLoader = PostsLoader(.Default) + private var explores:[ExploreSource] = [] + + var dataUrl:String? + + override func viewDidLoad() { + super.viewDidLoad() +// self.tableView.separatorColor = UIColor(red:240.0/255.0, +// green: 240.0/255.0, blue: 240.0/255.0, +// alpha: 0.0) + } + + override func viewDidAppear(animated: Bool) { + super.viewDidAppear(animated) + + + + refreshContent() + self.tableView.reloadData() + } + + func refreshContent() { + loadPostsFromUrl(self.dataUrl!) + self.tableView.reloadData() + } + + func loadPostsFromUrl(dataUrl: String) { + + postsLoader.loadExploreSourcesFromUrl(url: dataUrl) { [weak self](sources) -> () in + if let selfView = self { + selfView.explores = sources + selfView.tableView.reloadData() + } + } + + } + + override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return explores.count + } + + override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + + let source = explores[indexPath.row] as ExploreSource + let thumbnailUrl = NSURL(string: source.img) + + let cellIdentifier = "Cell" + let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath:indexPath) as! ExploreTableCell + + cell.sourceTitle.text = source.title + cell.sourceTitle.lineBreakMode = NSLineBreakMode.ByWordWrapping + cell.sourceTitle.numberOfLines = 2 + + cell.sourceImg.sd_setImageWithURL(thumbnailUrl, placeholderImage: UIImage(named: "default")) + + cell.sourceImg.layer.cornerRadius = cell.sourceImg.frame.size.width / 2 + cell.sourceImg.clipsToBounds = true + cell.sourceImg.layer.borderWidth = 1 + cell.sourceImg.layer.borderColor = UIColor.blackColor().CGColor + + + cell.descriptionLabel.text = source.description + + //cell.sourceImg.layer.cornerRadius = cell.sourceTitle.frame.width / 2 + //cell.sourceImg.clipsToBounds = true + + return cell + + } + + +} diff --git a/librx/JsonPaser.swift b/librx/JsonPaser.swift index d69dfac..2bcfffe 100644 --- a/librx/JsonPaser.swift +++ b/librx/JsonPaser.swift @@ -14,20 +14,19 @@ struct JsonPaser{ private static let defaultThumail = "http://7pn5d3.com1.z0.glb.clouddn.com/9050353.png" static func parseProfile(json: JSON) -> Profile { - - print(json) + let id: Int = json["id"].int! + let avatar: String = json["avatar"].string! let name:String = json["name"].string! let email:String = json["email"].string! let followed:Bool = json["followed"].bool! - let startCount: Int = json["stars_count"].int! let likeCount: Int = json["likes_count"].int! let postsCount: Int = json["posts_count"].int! let followsCount: Int = json["follows_count"].int! let followersCount: Int = json["followers_count"].int! - return Profile(id: id, name: name,email: email, followed: followed, postsCount: postsCount, startCount: startCount, likeCount: likeCount, followsCount: followsCount, followersCount: followersCount) + return Profile(id: id, name: name, avatar: avatar, email: email, followed: followed, postsCount: postsCount, likeCount: likeCount, followsCount: followsCount, followersCount: followersCount) } diff --git a/librx/LibrxService.swift b/librx/LibrxService.swift index 0e776ce..cb5d877 100644 --- a/librx/LibrxService.swift +++ b/librx/LibrxService.swift @@ -53,7 +53,6 @@ struct LibrxService { case .SignIn: return "/api/v1/sign_in" case .SignUp: return "/api/v1/sign_up" case .Top: return "/api/v1/timeline" - case .Posts: return "/api/v1/posts" case .Post(let postId): return "/api/v1/posts/\(postId)" case .Follow(let userId): return "/api/v1/users/\(userId)/follow" @@ -75,7 +74,6 @@ struct LibrxService { case .UserLikedPosts(let userId): return "/api/v1/users/\(userId)/posts/liked" case .UserBookMarkPosts(let userId): return "/api/v1/users/\(userId)/posts/bookmarked" default: return "" - } } @@ -120,14 +118,19 @@ struct LibrxService { } - static func postsForUser(userId: Int, response: ([Post]) -> ()) { + static func postsForUrl(url: String, response: ([Post]) -> ()) { + let headers: [String:String] = buildHttpRequestHeader() + loadPostsByUrl(url, headers: headers, response: response) + + } + + static func postsForUser(userId: Int, response: ([Post]) -> ()) { let urlString = baseURL + ResourcePath.UserPosts(userId: userId).description let headers: [String:String] = buildHttpRequestHeader() loadPostsByUrl(urlString, headers: headers, response: response) - } static func postsForUserBookMark(userId: Int, response: ([Post]) -> ()) { @@ -135,7 +138,6 @@ struct LibrxService { let urlString = baseURL + ResourcePath.UserBookMarkPosts(userId: userId).description let headers: [String:String] = buildHttpRequestHeader() - print(urlString) loadPostsByUrl(urlString, headers: headers, response: response) } @@ -168,30 +170,57 @@ struct LibrxService { } - - static func loadPostsByUrl(urlString: String, headers:[String:String], response: ([Post]) ->()) { - print(urlString) Alamofire.request(.GET, urlString, headers: headers) .response{ (request, res, data, error) in - + let json = JSON(data: data!) var posts:[Post] = [] - print(json) - for index in 0.. ()) { + + Alamofire.request(.GET, urlString).response{ + (request, _, data, error) in + + let json = JSON(data:data!) + + var sources: [ExploreSource] = [] + + for index in 0..()) { let urlString = baseURL + ResourcePath.SignIn.description @@ -210,8 +239,6 @@ struct LibrxService { let email = data["user"]["email"].stringValue let id = data["user"]["id"].intValue - print(id) - do { let payload = try JWT.decode(jwt, algorithm: .HS256(email)) @@ -263,7 +290,6 @@ struct LibrxService { doPostRequest(urlString) } - static func viewPost(postId: Int){ diff --git a/librx/PostsLoader.swift b/librx/PostsLoader.swift index 4bd246e..e511af4 100644 --- a/librx/PostsLoader.swift +++ b/librx/PostsLoader.swift @@ -11,6 +11,7 @@ import Foundation class PostsLoader { typealias PostfixLoadCompetion = (posts:[Post]) ->() + typealias ExplorefixLoadCompetion = (sources: [ExploreSource]) ->() enum PostSection: CustomStringConvertible { @@ -51,7 +52,7 @@ class PostsLoader { private let keyword: String! private let section: PostSection - init(_ section: PostSection = .Default) { + init(_ section: PostSection = .RecentTimeLine) { self.section = section switch (section){ case let .Search(keyword): @@ -62,6 +63,20 @@ class PostsLoader { } + func loadExploreSourcesFromUrl(page: Int=1, url: String, completion: ExplorefixLoadCompetion) { + + if isLoading { + return + } + + isLoading = true + + return exploreSourcesFromUrl(url, completion: completion) + + } + + + func load(page: Int=1, completion: PostfixLoadCompetion){ if isLoading { @@ -82,6 +97,14 @@ class PostsLoader { } + func exploreSourcesFromUrl(url: String, completion: ExplorefixLoadCompetion){ + + LibrxService.loadExploreSourcesByUrl(url) { sources in + completion(sources: sources) + } + + } + func postsByUser(userId: Int, completion: PostfixLoadCompetion) { LibrxService.postsForUser(userId){ [weak self] posts in @@ -94,6 +117,7 @@ class PostsLoader { } + func postsByMe(completion: PostfixLoadCompetion) { LibrxService.postsForMyPosts(){ [weak self] posts in diff --git a/librx/Profile.swift b/librx/Profile.swift index 3b2d53a..ea5b713 100644 --- a/librx/Profile.swift +++ b/librx/Profile.swift @@ -12,9 +12,9 @@ class Profile { let id: Int let name: String + let avatar: String let email: String let followed: Bool - let startCount: Int let likeCount: Int let postsCount: Int let followsCount: Int @@ -22,10 +22,10 @@ class Profile { init( id: Int, name: String, + avatar: String, email: String, followed: Bool, postsCount: Int, - startCount: Int, likeCount: Int, followsCount: Int, followersCount: Int @@ -33,11 +33,11 @@ class Profile { self.id = id self.name = name + self.avatar = avatar self.email = email self.followed = followed self.postsCount = postsCount self.likeCount = likeCount - self.startCount = startCount self.followersCount = followersCount self.followsCount = followsCount diff --git a/librx/ProfileViewController.swift b/librx/ProfileViewController.swift index 0afa3b1..97d7d0d 100644 --- a/librx/ProfileViewController.swift +++ b/librx/ProfileViewController.swift @@ -42,6 +42,7 @@ class ProfileViewController: UIViewController{ screenWidth = screenSize.width screenHeight = screenSize.height + self.avatarImageView.layer.cornerRadius = self.avatarImageView.frame.width / 2 self.avatarImageView.clipsToBounds = true self.avatarImageView.layer.borderWidth = 2 @@ -71,6 +72,10 @@ class ProfileViewController: UIViewController{ LibrxService.profile(userId) { [weak self](profile) -> () in if let selfView = self { + + print(profile.avatar) + let avatar = NSURL(string: profile.avatar) + selfView.avatarImageView.sd_setImageWithURL(avatar, placeholderImage: UIImage(named: "default")) selfView.nameLabel.text = profile.name selfView.subTitleLabel.text = "简介:\(profile.email)" selfView.followerNumLabel.text = String(profile.followersCount) @@ -87,6 +92,8 @@ class ProfileViewController: UIViewController{ LibrxService.me { [weak self](profile) -> () in if let selfView = self { + let avatar = NSURL(string: profile.avatar) + selfView.avatarImageView.sd_setImageWithURL(avatar, placeholderImage: UIImage(named: "default")) selfView.nameLabel.text = profile.name selfView.subTitleLabel.text = "简介:\(profile.email)" selfView.followerNumLabel.text = String(profile.followersCount) @@ -117,7 +124,6 @@ class ProfileViewController: UIViewController{ @IBAction func segmentSwicth(sender: UISegmentedControl) { - print(sender.selectedSegmentIndex) self.containerViewController.turnToPage(sender.selectedSegmentIndex) } diff --git a/librx/SettingTableViewController.swift b/librx/SettingTableViewController.swift index 375cfe1..6078eac 100644 --- a/librx/SettingTableViewController.swift +++ b/librx/SettingTableViewController.swift @@ -23,7 +23,7 @@ class SettingTableViewController: UITableViewController { } override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { - print(indexPath.row) + } @IBAction func LogoutButtonPressed(sender: AnyObject) { diff --git a/librx/StorysTableViewController.swift b/librx/StorysTableViewController.swift index 4bd1098..aecc984 100644 --- a/librx/StorysTableViewController.swift +++ b/librx/StorysTableViewController.swift @@ -12,7 +12,6 @@ import SDWebImage class StorysTableViewController: UITableViewController { @IBOutlet weak var titleLabel: UILabel! - @IBOutlet weak var shareButton: UIBarButtonItem! private var timer: NSTimer! private var firstTime = true @@ -28,12 +27,6 @@ class StorysTableViewController: UITableViewController { var postSection : PostsLoader.PostSection = .Default { didSet { postsLoader = PostsLoader(postSection) - switch (postSection) { - case .Default: - self.titleLabel.text = "News" - default: - self.titleLabel.text = "Others" - } } } @@ -59,22 +52,6 @@ class StorysTableViewController: UITableViewController { self.tableView.estimatedRowHeight = 100 self.tableView.rowHeight = UITableViewAutomaticDimension - loginStateChange = LoginStateHandler(handler: { [weak self](state) -> () in - - if state == .LoggedIn { - self!.shareButton.image = UIImage(named: "Plus") - } else { - self!.shareButton.image = nil - } - - }) - - - if let _ = LocalStore.accessToken() { - shareButton.image = UIImage(named: "Plus") - } else { - shareButton.image = nil - } // Table View 站位 let tableFooterView:UIView = UIView() @@ -177,6 +154,7 @@ class StorysTableViewController: UITableViewController { } + } override func scrollViewDidEndDecelerating(scrollView: UIScrollView) { @@ -209,14 +187,13 @@ class StorysTableViewController: UITableViewController { func refreshContent() { - print("refresh Content") + print("refresh Content from default api") loadPosts() + timer = NSTimer.scheduledTimerWithTimeInterval(4.0, target: self, selector: "endOfWork", userInfo: nil, repeats: true) } func loadMore(sender:UIButton) { - - print("load more.........") } @@ -228,6 +205,8 @@ class StorysTableViewController: UITableViewController { } } + + func loadPosts() { postsLoader.load(completion: { [unowned self] posts in diff --git a/librx/WebViewController.swift b/librx/WebViewController.swift index 85ab0fb..8f093b0 100644 --- a/librx/WebViewController.swift +++ b/librx/WebViewController.swift @@ -187,7 +187,6 @@ extension WebViewController: UIScrollViewDelegate{ extension WebViewController: UIWebViewDelegate{ func webViewDidFinishLoad(webView: UIWebView) { - print("load compeleted") self.activeIndicatorView.hidden = true }