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,6 +17,7 @@ | ||
| 17 | 17 | ||
| 18 | @interface CNHomeViewController () | 18 | @interface CNHomeViewController () |
| 19 | @property (nonatomic, strong) NSMutableArray *data; | 19 | @property (nonatomic, strong) NSMutableArray *data; |
| 20 | +@property (nonatomic, strong) UIButton *reFreshBtn; | ||
| 20 | 21 | ||
| 21 | @end | 22 | @end |
| 22 | 23 | ||
| @@ -28,12 +29,18 @@ | @@ -28,12 +29,18 @@ | ||
| 28 | NSDictionary *parameters = @{@"params":@"{\"plat\":\"i\",\"version\":\"5.0\",\"appid\":\"gxb\",\"pageUUID\":\"852cde69-ecd8-11e6-b52e-c7d8a7a18cc4\",\"pageType\":\"channelList\"}"}; | 29 | NSDictionary *parameters = @{@"params":@"{\"plat\":\"i\",\"version\":\"5.0\",\"appid\":\"gxb\",\"pageUUID\":\"852cde69-ecd8-11e6-b52e-c7d8a7a18cc4\",\"pageType\":\"channelList\"}"}; |
| 29 | if (![[Reachability reachabilityForInternetConnection] currentReachabilityStatus]) { | 30 | if (![[Reachability reachabilityForInternetConnection] currentReachabilityStatus]) { |
| 30 | [AlertViewTool showHUDViewText:CustomStr(@"NetworkiInterruption")]; | 31 | [AlertViewTool showHUDViewText:CustomStr(@"NetworkiInterruption")]; |
| 32 | + if (!_reFreshBtn &&self.data.count == 0) { | ||
| 33 | + [self.view addSubview:self.reFreshBtn]; | ||
| 34 | + } | ||
| 31 | return; | 35 | return; |
| 32 | } | 36 | } |
| 33 | [AlertViewTool showHUDView]; | 37 | [AlertViewTool showHUDView]; |
| 34 | 38 | ||
| 35 | [XWHTTPTool POST:strUrl params:parameters success:^(id json) { | 39 | [XWHTTPTool POST:strUrl params:parameters success:^(id json) { |
| 36 | 40 | ||
| 41 | + if (self->_reFreshBtn) { | ||
| 42 | + [self->_reFreshBtn removeFromSuperview]; | ||
| 43 | + } | ||
| 37 | [AlertViewTool hideHUDView]; | 44 | [AlertViewTool hideHUDView]; |
| 38 | 45 | ||
| 39 | // 请求成功,解析数据 | 46 | // 请求成功,解析数据 |
| @@ -109,13 +116,18 @@ | @@ -109,13 +116,18 @@ | ||
| 109 | } else { | 116 | } else { |
| 110 | [AlertViewTool hideHUDView]; | 117 | [AlertViewTool hideHUDView]; |
| 111 | [AlertViewTool showHUDViewText:dic[@"errorMessage"]]; | 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 | } failure:^(NSError *error) { | 125 | } failure:^(NSError *error) { |
| 116 | [AlertViewTool hideHUDView]; | 126 | [AlertViewTool hideHUDView]; |
| 117 | [AlertViewTool showHUDViewText:CustomStr(@"ServerBusy")]; | 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 | - (void)viewWillAppear:(BOOL)animated { | 133 | - (void)viewWillAppear:(BOOL)animated { |
| @@ -193,6 +205,20 @@ | @@ -193,6 +205,20 @@ | ||
| 193 | } | 205 | } |
| 194 | */ | 206 | */ |
| 195 | #pragma mark - Lazy loading | 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 | - (ZXWSegmentControl *)segmentControl{ | 222 | - (ZXWSegmentControl *)segmentControl{ |
| 197 | if (!_segmentControl) { | 223 | if (!_segmentControl) { |
| 198 | //initStaticTitlesWithFrame | 224 | //initStaticTitlesWithFrame |