如果当前个人中心不是非当前用户,根据profile返回结果判断是否已关注该用户

This commit is contained in:
ylzheng
2015-10-26 23:24:17 +08:00
parent 94db8fb6f8
commit b19a171a24
2 changed files with 49 additions and 6 deletions
+6 -3
View File
@@ -273,7 +273,7 @@
</connections>
</containerView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="CNw-ot-yn7">
<rect key="frame" x="344" y="120" width="54" height="20"/>
<rect key="frame" x="353" y="120" width="54" height="20"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="54" id="PgZ-bN-3PP"/>
@@ -284,6 +284,9 @@
<state key="normal" title="关注">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="toggleFollowUser:" destination="rvR-19-yLR" eventType="touchUpInside" id="RzK-wa-lFX"/>
</connections>
</button>
</subviews>
<animations/>
@@ -341,7 +344,7 @@
<constraint firstItem="zAW-lF-yk5" firstAttribute="centerX" secondItem="rID-rz-Ikg" secondAttribute="centerX" id="l7d-Pw-f2I"/>
<constraint firstItem="SIX-Qg-kL0" firstAttribute="top" secondItem="XGc-Dl-Wje" secondAttribute="bottom" constant="8" id="lJd-lK-eW0"/>
<constraint firstAttribute="bottom" secondItem="9w4-mx-yar" secondAttribute="bottom" constant="33" id="ltj-P3-Zb4"/>
<constraint firstItem="CNw-ot-yn7" firstAttribute="leading" secondItem="yp4-E4-vOS" secondAttribute="trailing" constant="-9" id="m3E-WV-fnn"/>
<constraint firstItem="CNw-ot-yn7" firstAttribute="leading" secondItem="yp4-E4-vOS" secondAttribute="trailing" id="m3E-WV-fnn"/>
<constraint firstItem="yp4-E4-vOS" firstAttribute="top" secondItem="bPm-kp-unG" secondAttribute="bottom" id="muU-fk-uVr"/>
<constraint firstItem="9w4-mx-yar" firstAttribute="leading" secondItem="XGc-Dl-Wje" secondAttribute="leading" constant="-15" id="nFx-po-sOi"/>
<constraint firstItem="9w4-mx-yar" firstAttribute="top" secondItem="SIX-Qg-kL0" secondAttribute="bottom" constant="2" id="nHR-xx-SFd"/>
@@ -1585,6 +1588,6 @@
</resources>
<inferredMetricsTieBreakers>
<segue reference="dIc-VY-jD3"/>
<segue reference="cuN-Eg-MZE"/>
<segue reference="bKV-Tl-jmb"/>
</inferredMetricsTieBreakers>
</document>
+43 -3
View File
@@ -23,6 +23,7 @@ class ProfileViewController: UIViewController{
private var screenSize: CGRect!
private var screenWidth: CGFloat!
private var screenHeight: CGFloat!
private var isFollowed: Bool = true
//
var isMe:Bool = true
@@ -49,6 +50,7 @@ class ProfileViewController: UIViewController{
self.followButton.layer.borderWidth = 1
self.followButton.layer.borderColor = UIColor.whiteColor().CGColor
self.followButton.hidden = true
navigationController?.navigationBar.backgroundColor = UIColor.whiteColor()
navigationController?.navigationBar.tintColor = UIColor.whiteColor()
@@ -62,10 +64,8 @@ class ProfileViewController: UIViewController{
super.viewDidDisappear(animated)
if self.isMe {
loadMeProfile()
self.followButton.hidden = true
} else{
loadUserProfile(userId!)
print(">>>> \(LocalStore.accessUserId())")
}
}
@@ -81,6 +81,19 @@ class ProfileViewController: UIViewController{
selfView.subTitleLabel.text = "简介:\(profile.email)"
selfView.followerNumLabel.text = String(profile.followersCount)
selfView.follosNumLabel.text = String(profile.followsCount)
if let loginEdUserId = LocalStore.accessUserId() {
if selfView.userId != loginEdUserId {
if profile.followed {
selfView.followButton.setTitle("已关注", forState: .Normal)
} else {
selfView.followButton.setTitle("关注", forState: .Normal)
}
selfView.followButton.hidden = false
}
}
}
}
@@ -99,6 +112,20 @@ class ProfileViewController: UIViewController{
selfView.subTitleLabel.text = "简介:\(profile.email)"
selfView.followerNumLabel.text = String(profile.followersCount)
selfView.follosNumLabel.text = String(profile.followsCount)
if let loginEdUserId = LocalStore.accessUserId() {
if selfView.userId != loginEdUserId {
if profile.followed {
selfView.followButton.setTitle("已关注", forState: .Normal)
} else {
selfView.followButton.setTitle("关注", forState: .Normal)
}
selfView.followButton.hidden = false
}
}
}
}
@@ -107,7 +134,7 @@ class ProfileViewController: UIViewController{
if let strongSelf = self {
strongSelf.dismissViewControllerAnimated(true, completion: nil)
}
})
})
}
@@ -117,6 +144,19 @@ class ProfileViewController: UIViewController{
}
@IBAction func toggleFollowUser(sender: AnyObject) {
if self.isFollowed {
self.isFollowed = false
self.followButton.setTitle("关注", forState: .Normal)
return
} else {
self.isFollowed = true
self.followButton.setTitle("已关注", forState: .Normal)
return
}
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {