////? AddressBookViewController.h//? QRCodeScanApp////? Created by 密碼123 on 16/9/18.//? Copyright ? 2016年 密碼123. All rights reserved.//#import@interface AddressBookViewController : CustomeNavigationViewController@end
////? AddressBookViewController.m//? QRCodeScanApp////? Created by 密碼123 on 16/9/18.//? Copyright ? 2016年 密碼123. All rights reserved.//#import "MymemberModel.h"#import "MyMemberCell.h"#import "memberFirstSectionCell.h"#import "GroupNewsTwoCell.h"#import "CFPopView.h"#import "CFFuncModel.h"#import "GroupNewsViewController.h"#import "NewGroupViewController.h"#import "AddressBookViewController.h"#import "UploadGroupViewController.h"#import "LZActionSheet.h"@interface AddressBookViewController (){? ? ? ? NSMutableArray *_sectionAry;? ? ? ? UIView *_theBgView;}@property (nonatomic,strong) UITableView *tvContent;@property (nonatomic, strong) CFPopView *popView;@property (nonatomic,retain) NSMutableArray *dataList;@property (strong,nonatomic) NSMutableArray? *searchList;@property (nonatomic,strong) UITableView *tableView;@property (nonatomic,strong) UISearchController *searchController;@property (nonatomic,retain) NSArray *imgOfFirstSectionAry;@property (nonatomic,retain) NSArray *titleOfFirstSectionAry;@end@implementation AddressBookViewController- (void)viewDidLoad {? ? [super viewDidLoad];? ? // Do any additional setup after loading the view.? ? self.view.backgroundColor=[UIColor colorWithRed:243/255.0 green:243/255.0 blue:243/255.0 alpha:1.0];? ? [self initNavigationBar];? ? ? ? ? ? [self initWithcontrols];? ? ? ? [self initDatasource];? ? [self ZYHHandleData];? ? }-(void)viewWillDisappear:(BOOL)animated{? ? [super viewWillDisappear:animated];? ? if (self.popView.isShow)? ? {? ? ? ? [self.popView dismissFromKeyWindow];? ? ? ? [_theBgView removeFromSuperview];? ? }? ? }-(void)addPopview{? ? NSArray *dictArr=@[@{@"title":@"新建群組", @"iconName":@"4E48C566-B345-4125-A7C7-F7B9C9AB3C2B.png"},@{@"title":@"導入會員", @"iconName":@"CEF58191-4478-4CFD-B37E-8DF7271C267C.png"}];? ? self.popView = [CFPopView popViewWithFuncDicts:dictArr withpoint:CGPointMake(SCREEN_WIDTH-10-125, 64)];? ? ? ? __weak typeof (self) weakSelf = self;? ? ? ? ? ? self.popView.myFuncBlock = ^(NSInteger index){? ? ? ? ? ? ? ? NSLog(@"%ld", index);? ? ? ? switch (index) {? ? ? ? ? ? case 0:? ? ? ? ? ? {? ? ? ? ? ? ? ? [weakSelf doRemoveView];? ? ? ? ? ? ? ? NewGroupViewController *NewGroupVC=[[NewGroupViewController alloc]init];? ? ? ? ? ? ? ? NewGroupVC.hidesBottomBarWhenPushed = YES;? ? ? ? ? ? ? ? [weakSelf.navigationController pushViewController:NewGroupVC animated:YES];? ? ? ? ? ? }? ? ? ? ? ? ? ? break;? ? ? ? ? ? case 1:? ? ? ? ? ? {? ? ? ? ? ? ? ? [weakSelf doRemoveView];? ? ? ? ? ? ? ? UploadGroupViewController *UploadGroupVC=[[UploadGroupViewController alloc]init];? ? ? ? ? ? ? ? UploadGroupVC.hidesBottomBarWhenPushed = YES;? ? ? ? ? ? ? ? [weakSelf.navigationController pushViewController:UploadGroupVC animated:YES];? ? ? ? ? ? }? ? ? ? ? ? ? ? break;? ? ? ? ? ? default:? ? ? ? ? ? ? ? break;? ? ? ? }? ? ? ? ? ? ? ? [weakSelf.popView dismissFromKeyWindow];? ? };}-(void)initNavigationBar{? ? [self setNavLeftItemImage:[[UIImage imageNamed:@"mass-textiong-sercret.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] withSelector:@selector(leftTouch:)];? ? [self setNavRightItem:[[UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e929 ", 20, [HqewUtil colorWithHexString:@"#50acee"])] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] withSelector:@selector(rightTouch:)];? ? [self setNavtitleItem:@"會員"];}//刷新- (void) addRefreshHeaderView {? ? __unsafe_unretained typeof(self) vc = self;? ? // 添加上拉刷新尾部控件? ? [_tvContent addLegendHeaderWithRefreshingBlock:^{? ? ? ? // 進入刷新狀態(tài)就會回調這個Block? ? ? ? ? ? ? ? dispatch_async(dispatch_get_main_queue(), ^{? ? ? ? [vc.tvContent.header endRefreshing];? ? ? ? ? ? [vc ZYHHandleData];? ? ? ? });? ? }];}-(void)initWithcontrols{? ? _tvContent = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-64) style:UITableViewStylePlain];? ? _tvContent.separatorColor = [UIColor clearColor];? ? _tvContent.dataSource = self;? ? _tvContent.delegate = self;? ? _tvContent.separatorStyle = UITableViewCellSeparatorStyleSingleLine;? ? [self.view addSubview:_tvContent];? ? [self addRefreshHeaderView];? ? ? ? ? ? ? ? ? ? /*searchBar*/? ? _searchController=[[UISearchController alloc]initWithSearchResultsController:nil];? ? ? ? _searchController.delegate=self;? ? ? ? _searchController.searchResultsUpdater=self;? ? ? ? _searchController.dimsBackgroundDuringPresentation=NO;? ? ? ? _searchController.obscuresBackgroundDuringPresentation=NO;? ? ? ? _searchController.hidesNavigationBarDuringPresentation=NO;? ? ? ? ? ? _searchController.searchBar.frame=CGRectMake(self.searchController.searchBar.frame.origin.x, self.searchController.searchBar.frame.origin.y, self.searchController.searchBar.frame.size.width, 44);? ? ? ? _searchController.searchBar.placeholder = @"搜索";? ? ? ? ? ? _searchController.searchBar.backgroundColor=[UIColor clearColor];? ? [_searchController.searchBar setSearchFieldBackgroundImage:[UIImage imageNamed:@"contact_searchbg_ios6"] forState:UIControlStateNormal];? ? ? ? ? ? //隱藏搜索圖標? ? [_searchController.searchBar setImage:[UIImage imageNamed:@"contact_search_btn"] forSearchBarIcon:UISearchBarIconSearch state:UIControlStateDisabled];? ? _searchController.searchBar.keyboardType =? UIKeyboardTypeDefault;? ? _searchController.searchBar.delegate = self;? ? ? ? // 修改searchBar的背景顏色? ? float version = [[[UIDevice currentDevice] systemVersion] floatValue];? ? if ([_searchController.searchBar respondsToSelector:@selector(barTintColor)])? ? {? ? ? ? float iosVersion7_1 = 7.1;? ? ? ? ? ? ? ? if (version >= iosVersion7_1) {? ? ? ? ? ? [[[[_searchController.searchBar.subviews objectAtIndex:0] subviews] objectAtIndex:0] removeFromSuperview];? ? ? ? ? ? [_searchController.searchBar setBackgroundColor:[UIColor colorWithRed:243/255.0 green:243/255.0 blue:243/255.0 alpha:1.0]];? ? ? ? }? ? ? ? else {? ? ? ? ? ? [_searchController.searchBar setBarTintColor:[UIColor clearColor]];? ? ? ? ? ? [_searchController.searchBar setBackgroundColor:[UIColor colorWithRed:243/255.0 green:243/255.0 blue:243/255.0 alpha:1.0]];? ? ? ? }? ? }? ? else? ? {? ? ? ? [[_searchController.searchBar.subviews objectAtIndex:0] removeFromSuperview];? ? ? ? [_searchController.searchBar setBackgroundColor:[UIColor colorWithRed:243/255.0 green:243/255.0 blue:243/255.0 alpha:1.0]];? ? }? ? ? ? //? ? //隱藏找資源上面的搜索框? ? _tvContent.tableHeaderView = _searchController.searchBar;}-(void)initDatasource{? ? _sectionAry=[[NSMutableArray alloc]initWithObjects:@"",@"我的會員", nil];? ? self.dataList=[NSMutableArray arrayWithCapacity:0];? ? ? ? _imgOfFirstSectionAry=@[@"3E8F56B2-EE72-4824-9184-0A265012F28B.png",@"5C051F2A-2A5A-4076-87EA-9E37F4E59C53.png",@"F3AE7A16-0854-4AFE-88D0-89DFDC1EAD77.png",@"F91EBB54-46C5-45B3-8D90-CF9FCD486BB7.png"];? ? _titleOfFirstSectionAry=@[@"新的會員",@"俱樂部",@"標簽",@"活動群組"];}#pragma mark - UITableViewDelegate,UITableViewDataSource- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{? ? if (self.searchController.active)? ? {? ? ? ? return 0;? ? }? ? else? ? {? ? ? ? return? _sectionAry.count;? ? }}- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{? ? if (self.searchController.active)? ? {? ? ? ? return 0;? ? }? ? else? ? {? ? ? ? if (section==0)? ? ? ? {? ? ? ? ? ? return 4;? ? ? ? }? ? ? ? else? ? ? ? {? ? ? ? ? ? return self.dataList.count;? ? ? ? }? ? }}- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{? ? return 55;}-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{? ? if (self.searchController.active)? ? {? ? ? ? return 0.01;? ? }? ? else? ? {? ? ? ? if (section==0)? ? ? ? {? ? ? ? ? ? return 0.01;? ? ? ? }? ? ? ? else? ? ? ? {? ? ? ? ? ? return 36.0;? ? ? ? }? ? }}-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{? ? if (_searchController.active)? ? {? ? ? ? return nil;? ? }? ? else? ? {? ? ? ? UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];? ? ? ? btn.frame=CGRectMake(0, 0, SCREEN_WIDTH, 44);? ? ? ? ? ? ? ? UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH-10, 44)];? ? ? ? label.text=_sectionAry[section];? ? ? ? label.font=[UIFont systemFontOfSize:15];? ? ? ? btn.backgroundColor=[UIColor colorWithRed:243/255.0 green:243/255.0 blue:243/255.0 alpha:1.0];? ? ? ? label.textColor=[UIColor grayColor];? ? ? ? ? ? ? ? label.backgroundColor=[UIColor clearColor];? ? ? ? ? ? ? ? [btn addSubview:label];? ? ? ? ? ? ? ? return btn;? ? }? ? }- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{? ? if (_searchController.active)? ? {? ? ? ? static NSString *flag = @"cell";? ? ? ? UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:flag];? ? ? ? if (!cell) {? ? ? ? ? ? cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:flag];? ? ? ? }? ? ? ? ? ? ? ? [cell.textLabel setText:self.searchList[indexPath.row]];? ? ? ? ? ? ? ? return cell;? ? }? ? else? ? {? ? ? ? if (indexPath.section==0)? ? ? ? {? ? ? ? ? ? static NSString *flag = @"memberFirstSectionCell";? ? ? ? ? ? memberFirstSectionCell *cell =[tableView dequeueReusableCellWithIdentifier:flag];? ? ? ? ? ? if (!cell) {? ? ? ? ? ? ? ? cell=[[memberFirstSectionCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:flag withHeight:55.0];? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? ? ? [cell setFirstCell:[_titleOfFirstSectionAry objectAtIndex:indexPath.row] and:[_imgOfFirstSectionAry objectAtIndex:indexPath.row]];? ? ? ? ? ? ? ? ? ? ? ? return cell;? ? ? ? }? ? ? ? else? ? ? ? {? ? ? ? ? ? static NSString *strIdentifer = @"MyMemberCell";? ? ? ? ? ? MyMemberCell *cell = [tableView dequeueReusableCellWithIdentifier:strIdentifer];? ? ? ? ? ? if (!cell) {? ? ? ? ? ? ? ? cell=[[MyMemberCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:strIdentifer withHeight:55.0];? ? ? ? ? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? if (indexPath.row0)
{
[_tvContent reloadData];
}
}
}
else
{
[SVProgressHUD showInfoWithStatus:[NSString stringWithFormat:@"%@",[dic objectForKey:@"msg"]]];
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"%@", error);
[self.tableView.header endRefreshing];
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
}];
}
/*
#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.
}
*/
@end