Commit 17615649e946a438971cab56187980cde9a61f54
1 parent
bbdd9c95
网络不好的情况下,打开首页空白,网络恢复后无法下拉刷新请求
增加了刷新按钮
Showing
1 changed file
with
27 additions
and
1 deletions
CNLiveScioLive/Pages/Home/CNHomeViewController.m
| ... | ... | @@ -17,6 +17,7 @@ |
| 17 | 17 | |
| 18 | 18 | @interface CNHomeViewController () |
| 19 | 19 | @property (nonatomic, strong) NSMutableArray *data; |
| 20 | +@property (nonatomic, strong) UIButton *reFreshBtn; | |
| 20 | 21 | |
| 21 | 22 | @end |
| 22 | 23 | |
| ... | ... | @@ -28,12 +29,18 @@ |
| 28 | 29 | NSDictionary *parameters = @{@"params":@"{\"plat\":\"i\",\"version\":\"5.0\",\"appid\":\"gxb\",\"pageUUID\":\"852cde69-ecd8-11e6-b52e-c7d8a7a18cc4\",\"pageType\":\"channelList\"}"}; |
| 29 | 30 | if (![[Reachability reachabilityForInternetConnection] currentReachabilityStatus]) { |
| 30 | 31 | [AlertViewTool showHUDViewText:CustomStr(@"NetworkiInterruption")]; |
| 32 | + if (!_reFreshBtn &&self.data.count == 0) { | |
| 33 | + [self.view addSubview:self.reFreshBtn]; | |
| 34 | + } | |
| 31 | 35 | return; |
| 32 | 36 | } |
| 33 | 37 | [AlertViewTool showHUDView]; |
| 34 | 38 | |
| 35 | 39 | [XWHTTPTool POST:strUrl params:parameters success:^(id json) { |
| 36 | 40 | |
| 41 | + if (self->_reFreshBtn) { | |
| 42 | + [self->_reFreshBtn removeFromSuperview]; | |
| 43 | + } | |
| 37 | 44 | [AlertViewTool hideHUDView]; |
| 38 | 45 | |
| 39 | 46 | // 请求成功,解析数据 |
| ... | ... | @@ -109,13 +116,18 @@ |
| 109 | 116 | } else { |
| 110 | 117 | [AlertViewTool hideHUDView]; |
| 111 | 118 | [AlertViewTool showHUDViewText:dic[@"errorMessage"]]; |
| 119 | + if (!self->_reFreshBtn &&self.data.count == 0) { | |
| 120 | + [self.view addSubview:self.reFreshBtn]; | |
| 121 | + } | |
| 112 | 122 | } |
| 113 | 123 | |
| 114 | 124 | |
| 115 | 125 | } failure:^(NSError *error) { |
| 116 | 126 | [AlertViewTool hideHUDView]; |
| 117 | 127 | [AlertViewTool showHUDViewText:CustomStr(@"ServerBusy")]; |
| 118 | - | |
| 128 | + if (!self->_reFreshBtn &&self.data.count == 0) { | |
| 129 | + [self.view addSubview:self.reFreshBtn]; | |
| 130 | + } | |
| 119 | 131 | }]; |
| 120 | 132 | } |
| 121 | 133 | - (void)viewWillAppear:(BOOL)animated { |
| ... | ... | @@ -193,6 +205,20 @@ |
| 193 | 205 | } |
| 194 | 206 | */ |
| 195 | 207 | #pragma mark - Lazy loading |
| 208 | +- (UIButton *)reFreshBtn | |
| 209 | +{ | |
| 210 | + if (!_reFreshBtn) { | |
| 211 | + _reFreshBtn = [UIButton buttonWithType:UIButtonTypeCustom]; | |
| 212 | + _reFreshBtn.frame = CGRectMake(0, 0, 200, 44); | |
| 213 | + _reFreshBtn.center = self.view.center; | |
| 214 | + [_reFreshBtn setTitle:@"网络中断了,刷一刷吧~" forState:UIControlStateNormal]; | |
| 215 | + [_reFreshBtn setTitleColor:Color_Blue forState:UIControlStateNormal]; | |
| 216 | + _reFreshBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC" size:13]; | |
| 217 | + [_reFreshBtn addTarget:self action:@selector(getData) forControlEvents:UIControlEventTouchUpInside]; | |
| 218 | + } | |
| 219 | + return _reFreshBtn; | |
| 220 | + | |
| 221 | +} | |
| 196 | 222 | - (ZXWSegmentControl *)segmentControl{ |
| 197 | 223 | if (!_segmentControl) { |
| 198 | 224 | //initStaticTitlesWithFrame | ... | ... |