add message exercises
This commit is contained in:
@@ -8,22 +8,26 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface GiGaBaseViewController : UIViewController<UIGestureRecognizerDelegate,UINavigationControllerDelegate>
|
||||
@interface GiGaBaseViewController : UIViewController<UITableViewDelegate,UITableViewDataSource>
|
||||
{
|
||||
UIView *emptyView;
|
||||
UIView *_emptyView;
|
||||
UIView *_noNetWorkView;
|
||||
}
|
||||
|
||||
//- (void)setNavigationViewWithBGColor:(UIColor *)bgColor TitleColor:(UIColor *)titleColor;
|
||||
//- (void)setNavigationViewHidden:(BOOL)hidden;
|
||||
//- (void)addBackButtonWithImageName:(NSString *)imageName;
|
||||
//- (void)setBackButtonHidden:(BOOL)hidden;
|
||||
//- (void)setNavigationViewBottomLineHidden:(BOOL)hidden;
|
||||
//
|
||||
//- (void)addRightButtonWithBGImageName:(NSString *)rightImageName action:(SEL)rightAction;
|
||||
//
|
||||
//- (void)addRefreshHeaderFooterForTableView:(UITableView *)tableView
|
||||
// refreshHeaderSelector:(SEL)refreshHeaderSelector
|
||||
// refreshFooterSelector:(SEL)refreshFooterSelector;
|
||||
@property (nonatomic,strong) UIView * emptyView;
|
||||
@property (nonatomic,strong) UIView * noNetWorkView;
|
||||
|
||||
@property (nonatomic,strong) UITableView *tableView;
|
||||
|
||||
//网络改变回调Block,-1未知、0无网络、1蜂窝数据网络、2WiFi
|
||||
@property (nonatomic, copy) void(^ network)(AFNetworkReachabilityStatus status);
|
||||
//当前网络状态,-1未知、0无网络、1蜂窝数据网络、2WiFi
|
||||
@property (nonatomic, assign) AFNetworkReachabilityStatus currentNetworkStatus;
|
||||
|
||||
- (void)showNoNetWorkView;
|
||||
- (void)showEmptyView;
|
||||
|
||||
-(void)addNavTitile:(NSString *)title;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
//
|
||||
|
||||
#import "GiGaBaseViewController.h"
|
||||
#import "UIView+Toast.h"
|
||||
#import "GiGaNavTitileView.h"
|
||||
|
||||
@interface GiGaBaseViewController ()
|
||||
{
|
||||
@@ -15,6 +17,7 @@
|
||||
// SEL _rightBtnAction;
|
||||
// SEL _refreshHeaderSelector;
|
||||
// SEL _refreshFooterSelector;
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -24,21 +27,87 @@
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
[self.view addSubview:_tableView];
|
||||
[self testNetworkStatus];
|
||||
}
|
||||
|
||||
-(void)addNavTitile:(NSString *)title{
|
||||
|
||||
self.navigationItem.titleView = [[GiGaNavTitileView alloc] initWithString:title frame:CGRectMake(0, 0, 200, 44)];
|
||||
|
||||
}
|
||||
|
||||
//没有网络返回
|
||||
- (void)showNoNetWorkView
|
||||
{
|
||||
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
// if (self.currentNetworkStatus < 1) {
|
||||
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
//
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
-(void)showEmptyView{
|
||||
|
||||
}
|
||||
|
||||
-(void)testNetworkStatus{
|
||||
AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
|
||||
weakify(self);
|
||||
[manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
|
||||
weakSelf.currentNetworkStatus = status;
|
||||
if (weakSelf.network) weakSelf.network(status);
|
||||
switch (status) {
|
||||
case AFNetworkReachabilityStatusNotReachable:
|
||||
|
||||
[[UIApplication sharedApplication].keyWindow makeToast:@"哎呀,没有网络啦~"duration:1.6 position:CSToastPositionCenter];
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}] ;
|
||||
//开始检测
|
||||
[manager startMonitoring];
|
||||
}
|
||||
|
||||
//显示信息,并在设定延时后返回上级界面
|
||||
- (void)backWithShowMessage:(NSString *)message afterDelay:(CGFloat)delay
|
||||
{
|
||||
[[UIApplication sharedApplication].keyWindow makeToast:message duration:1.6 position:CSToastPositionCenter];
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self back];
|
||||
});
|
||||
}
|
||||
- (void)back
|
||||
{
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
}
|
||||
|
||||
-(UITableView*)tableView{
|
||||
|
||||
if (!_tableView) {
|
||||
|
||||
_tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
|
||||
}
|
||||
|
||||
return _tableView;
|
||||
}
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
/*
|
||||
#pragma mark - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||||
// Get the new view controller using [segue destinationViewController].
|
||||
// Pass the selected object to the new view controller.
|
||||
- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user