2323#import " SVPullToRefresh.h"
2424#import " EditTaskViewController.h"
2525#import " WebViewController.h"
26+ #import " EditTopicViewController.h"
2627
2728@interface TopicDetailViewController ()
2829@property (strong , nonatomic ) UITableView *myTableView;
@@ -70,7 +71,7 @@ - (void)viewDidLoad
7071 tableView;
7172 });
7273 _refreshControl = [[ODRefreshControl alloc ] initInScrollView: self .myTableView];
73- [_refreshControl addTarget: self action: @selector (refresh ) forControlEvents: UIControlEventValueChanged];
74+ [_refreshControl addTarget: self action: @selector (refreshTopic ) forControlEvents: UIControlEventValueChanged];
7475
7576 // 评论
7677 __weak typeof (self) weakSelf = self;
@@ -90,7 +91,7 @@ - (void)viewDidLoad
9091 _myMsgInputView.curProject = _curTopic.project ;
9192 _myMsgInputView.commentOfId = _curTopic.id ;
9293 }
93- [self refresh ];
94+ [self refreshTopic ];
9495}
9596
9697- (void )viewWillDisappear : (BOOL )animated {
@@ -117,6 +118,23 @@ - (void)didReceiveMemoryWarning
117118 // Dispose of any resources that can be recreated.
118119}
119120
121+ #pragma mark nav
122+ - (void )configNavBtn {
123+ [self .navigationItem setRightBarButtonItem: [self .curTopic canEdit ]? [UIBarButtonItem itemWithBtnTitle: @" 编辑" target: self action: @selector (editBtnClicked )]: nil animated: YES ];
124+ }
125+
126+ - (void )editBtnClicked {
127+ EditTopicViewController *vc = [[EditTopicViewController alloc ] init ];
128+ vc.curProTopic = self.curTopic ;
129+ vc.type = TopicEditTypeModify;
130+
131+ __weak typeof (self) weakSelf = self;
132+ vc.topicChangedBlock = ^(ProjectTopic *topic, TopicEditType type){
133+ [weakSelf refreshTopic ];
134+ };
135+ [self .navigationController pushViewController: vc animated: YES ];
136+ }
137+
120138#pragma mark UIMessageInputViewDelegate
121139- (void )messageInputView : (UIMessageInputView *)inputView sendText : (NSString *)text {
122140 [self sendCommentMessage: text];
@@ -139,13 +157,6 @@ - (void)messageInputView:(UIMessageInputView *)inputView heightToBottomChenged:(
139157}
140158
141159#pragma mark Refresh M
142- - (void )refresh {
143- [self refreshTopic ];
144- __weak typeof (self) weakSelf = self;
145- dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t )(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue (), ^{
146- [weakSelf refreshComments ];
147- });
148- }
149160
150161- (void )refreshComments {
151162 if (_curTopic.isLoading ) {
@@ -163,11 +174,15 @@ - (void)refreshTopic{
163174 [[Coding_NetAPIManager sharedManager ] request_ProjectTopic_WithObj: _curTopic andBlock: ^(id data, NSError *error) {
164175 [self .refreshControl endRefreshing ];
165176 if (data) {
166- [weakSelf.curTopic configWithRefreshedTopic: data];
177+ weakSelf.curTopic = data;
178+
167179 weakSelf.myMsgInputView .curProject = weakSelf.curTopic .project ;
168180 weakSelf.myMsgInputView .commentOfId = _curTopic.id ;
169181 weakSelf.myMsgInputView .toUser = nil ;
182+ [weakSelf configNavBtn ];
183+
170184 [weakSelf.myTableView reloadData ];
185+ [weakSelf refreshComments ];
171186 }
172187 }];
173188}
0 commit comments