码迷,mamicode.com
首页 > 移动开发 > 详细

ios 横向滑动

时间:2017-11-10 15:23:34      阅读:268      评论:0      收藏:0      [点我收藏+]

标签:nsbundle   uila   2017年   opp   i++   reload   get   etc   express   

 

关于ios oc 第一列固定为checkbox 其他列侧滑

 

  1   1 //
  2   2 //  searchResultViewController.m
  3   3 //  cardionNet2
  4   4 //
  5   5 //  Created by qiuy on 2017/11/7.
  6   6 //  Copyright ? 2017年 qiuy. All rights reserved.
  7   7 //
  8   8 
  9   9 #import "searchResultViewController.h"
 10  10 #import "MBProgressHUD.h"
 11  11 #import "listPageController.h"
 12  12 #import "ToppanConst.h"
 13  13 #import "listPageModel.h"
 14  14 #import "ViewForNavi.h"
 15  15 #import "listPageCell.h"
 16  16 #import "WhiteRaccoon.h"
 17  17 #import "TestCellViewController.h"
 18  18 #import "searchResultTitCell.h"
 19  19 #import "searchResultListCell.h"
 20  20 @interface searchResultViewController ()<ViewForNaviDelegate,NSXMLParserDelegate,UITableViewDelegate,UITableViewDataSource>{
 21  21 #define WIDTH [UIScreen mainScreen].bounds.size.width
 22  22 #define HEIGHT [UIScreen mainScreen].bounds.size.height
 23  23     //引入第三方加载
 24  24     MBProgressHUD *HUD;
 25  25     NSString*whereExpression;
 26  26     //中间转换
 27  27     NSDictionary *dic;
 28  28     NSMutableArray  *STUDY_TBLList;
 29  29     NSMutableArray  *DATA_TBLList;
 30  30     listPageModel *detailModel;
 31  31     listPageCell *cell;
 32  32     //DATA_TBL
 33  33     listPageModel *dataTblModel;
 34  34     //初期化为0 单条检索为 1
 35  35     NSString *strflg;
 36  36 @private
 37  37     NSString* destination;
 38  38     NSString* password;
 39  39     NSString* username;
 40  40     NSMutableArray * leaveRowList ;
 41  41     int port;
 42  42 }
 43  43 
 44  44 @property (strong, nonatomic) IBOutlet UITableView *detailedInfo;
 45  45 
 46  46 //标记当前标签,以索引找到XML文件内容
 47  47 @property (nonatomic, copy) NSString *currentElement;
 48  48 
 49  49 @property (weak, nonatomic) IBOutlet UIView *backView;
 50  50 @property (nonatomic, strong) UITableView *titleTableView;//标题TableView
 51  51 @property (nonatomic, strong) UITableView *infoTableView;//内容TableView
 52  52 @property (nonatomic, strong) UIScrollView *contentView;//内容容器
 53  53 @property (nonatomic, strong) NSArray *infoArr;//数组
 54  54 @property (nonatomic, strong) NSArray *infoArrTitleLeft;//标题数组
 55  55 @property (nonatomic, strong) NSArray *infoArrTitleRight;//标题数组
 56  56 
 57  57 @property (nonatomic, strong) UILabel *lblCheck;//标题Checkbox
 58  58 @property (nonatomic, strong) UILabel *lblState;//标题状态
 59  59 
 60  60 @end
 61  61 @implementation searchResultViewController{
 62  62     CGFloat _kOriginX;
 63  63     CGFloat _kScreenWidth;
 64  64     CGFloat _kScreenHeight;
 65  65     CGFloat _kOriginXLift;
 66  66 }
 67  67 
 68  68 - (void)viewDidLoad {
 69  69     [super viewDidLoad];
 70  70     //标题
 71  71     self.navigationController.interactivePopGestureRecognizer.enabled=NO;
 72  72     ViewForNavi *naviView = [[ViewForNavi alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 40)];
 73  73     [self.view addSubview:naviView];
 74  74     naviView.delegate = self;
 75  75     //设置标题
 76  76     [self didWarning];
 77  77     [self showMBProgressHUD];
 78  78     //检索链接web
 79  79     [self getOffesetUTCTimeSOAP];
 80  80     
 81  81 }
 82  82 #pragma mark --滑动做准备
 83  83 - (void)configData {
 84  84     _kScreenWidth = self.view.frame.size.width;
 85  85     _kScreenHeight = self.view.frame.size.height;
 86  86     _kOriginX = 100;
 87  87     _kOriginXLift =30;
 88  88     _infoArr = STUDY_TBLList;
 89  89     //标题数组
 90  90     _infoArrTitleRight= [[NSMutableArray alloc]init];
 91  91     _infoArrTitleRight = @[ @{@"title":@"状态"},
 92  92                             @{@"title":@"检查号"},
 93  93                             @{@"title":@"姓名"},
 94  94                             @{@"title":@"性别"},
 95  95                             @{@"title":@"诊断科室"},
 96  96                             @{@"title":@"登记时间"},
 97  97                             @{@"title":@"病人类别名称"},
 98  98                             @{@"title":@"检查名称"}];
 99  99     
100 100     _infoArrTitleLeft= [[NSMutableArray alloc]init];
101 101     _infoArrTitleLeft = @[@{@"title":@"  "}];
102 102     
103 103 }
104 104 #pragma mark --详细内容
105 105 //MARK:- 详细内容
106 106 - (void)configInfoView {
107 107     _titleTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 40, _kOriginXLift, _kScreenHeight-180) style:UITableViewStylePlain];
108 108     _titleTableView.dataSource = self;
109 109     _titleTableView.delegate = self;
110 110     _titleTableView.showsVerticalScrollIndicator = NO;
111 111     _titleTableView.showsHorizontalScrollIndicator = NO;
112 112     _titleTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
113 113     [self.backView addSubview:_titleTableView];
114 114     
115 115     _infoTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 40, 1000, _kScreenHeight-180) style:UITableViewStylePlain];
116 116     _infoTableView.delegate = self;
117 117     _infoTableView.dataSource = self;
118 118     _infoTableView.showsVerticalScrollIndicator = NO;
119 119     _infoTableView.showsHorizontalScrollIndicator = NO;
120 120     _infoTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
121 121     [_contentView addSubview:_infoTableView];
122 122 }
123 123 #pragma mark --设置标题
124 124 - (void)didWarning {
125 125     
126 126     STUDY_TBLList = [[NSMutableArray alloc]init];
127 127     DATA_TBLList = [[NSMutableArray alloc]init];
128 128     detailModel = [[listPageModel alloc]init];
129 129     strflg = @"0";
130 130     //标题
131 131     self.navigationController.interactivePopGestureRecognizer.enabled=NO;
132 132     ViewForNavi *naviView = [[ViewForNavi alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 40)];
133 133     [self.view addSubview:naviView];
134 134     naviView.delegate = self;
135 135     _detailedInfo.dataSource = self;
136 136     _detailedInfo.delegate = self;
137 137     // 注册cell
138 138     [self.detailedInfo registerNib:[UINib nibWithNibName:@"listPageCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"pool"];
139 139     
140 140 }
141 141 #pragma mark --头部视图
142 142 //MARK:- 头部视图
143 143 - (void)configTableHeader {
144 144     _contentView = [[UIScrollView alloc] initWithFrame:CGRectMake(_kOriginXLift, 0,  _kScreenWidth - _kOriginXLift , _kScreenHeight)];
145 145     _contentView.delegate = self;
146 146     _contentView.showsVerticalScrollIndicator = NO;
147 147     _contentView.showsHorizontalScrollIndicator = NO;
148 148     _contentView.contentSize = CGSizeMake(800, _kScreenHeight);
149 149     _contentView.bounces = NO;
150 150     //标题
151 151     [self.backView addSubview:_contentView];
152 152     self.lblCheck =[[UILabel alloc]init];
153 153     self.lblCheck = [self quickCreateLabelWith:0 width:20 title:@"  "];
154 154     [self.backView addSubview:self.lblCheck];
155 155     
156 156     for (int i = 0; i < _infoArrTitleRight.count; i++) {
157 157         CGFloat x = i * 100;
158 158         if(i == 0){
159 159             UILabel *label = [self quickCreateLabelWith:0 width:100 title:[[_infoArrTitleRight objectAtIndex: i] objectForKey:@"title"]];
160 160             NSLog(@"qqqqqqqq@%@",[[_infoArrTitleRight objectAtIndex: i] objectForKey:@"title"] );
161 161             // label.textAlignment = NSTextAlignmentCenter;
162 162             [_contentView addSubview:label];
163 163             
164 164         }else{
165 165             UILabel *label = [self quickCreateLabelWith:x width:100 title:[[_infoArrTitleRight objectAtIndex: i] objectForKey:@"title"]];
166 166             NSLog(@"qqqqqqqq@%@",[[_infoArrTitleRight objectAtIndex: i] objectForKey:@"title"] );
167 167             // label.textAlignment = NSTextAlignmentCenter;
168 168             [_contentView addSubview:label];
169 169             
170 170         }
171 171     }
172 172 }
173 173 #pragma mark --快速创建label
174 174 //MARK:- 快速创建label
175 175 - (UILabel *)quickCreateLabelWith:(CGFloat)left width:(CGFloat)width title:(NSString *)title {
176 176     UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(left, 10, width, 40)];
177 177     label.text = title;
178 178     //label.textAlignment = NSTextAlignmentCenter;
179 179     return label;
180 180 }
181 181 
182 182 #pragma mark--tableView有几行
183 183 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
184 184     return STUDY_TBLList.count;
185 185 }
186 186 //
187 187 #pragma mark--指定每一个cell的高度
188 188 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
189 189     UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
190 190     return cell.frame.size.height;
191 191     
192 192 }
193 193 #pragma mark--分组
194 194 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
195 195     return 1;
196 196 }
197 197 #pragma mark--table 赋值
198 198 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
199 199 {
200 200     
201 201     //life
202 202     if (tableView == _titleTableView) {
203 203         NSString *ident = @"titleTable";
204 204         searchResultTitCell *cell = [tableView dequeueReusableCellWithIdentifier:ident];
205 205         if (!cell) {
206 206             cell = [[searchResultTitCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"titleTable"];
207 207         }
208 208         if (indexPath.row%2 == 1) {
209 209             cell.backgroundColor = [UIColor colorWithRed:232.0/255.0 green:246.0/255.0 blue:255.0/255.0 alpha:1.0];
210 210         } else {
211 211             cell.backgroundColor = [UIColor whiteColor];
212 212         }
213 213         // [cell setDataWith:[_infoArr objectAtIndex:indexPath.row]];
214 214         listPageModel * cellModellistPage=[STUDY_TBLList objectAtIndex:indexPath.row];
215 215         [cell setDataWithStrcellModel:cellModellistPage];
216 216         
217 217         cell.myButton.tag =indexPath.row;
218 218         cell.selectionStyle = UITableViewCellSelectionStyleNone;
219 219         cell.onMyBlock = ^(NSIndexPath *indexPath){
220 220             NSLog(@"在tableviewController中处理---->%ld", (long)indexPath.row);
221 221             //  [cell.myButton setImage:[UIImage imageNamed:@"commonpagebutton.png"] forState:UIControlStateNormal];
222 222             //新List
223 223             leaveRowList = [[NSMutableArray alloc]init];
224 224             int   j =0;
225 225             for (listPageModel *detailModel in STUDY_TBLList) {
226 226                 if (j==indexPath.row) {
227 227                     if ([detailModel.picture isEqual:@""]||[detailModel.picture isEqual:nil]||detailModel.picture ==nil) {
228 228                         detailModel.picture = @"toppan_duihao";
229 229                     }else{
230 230                         detailModel.picture = @"";
231 231                     }
232 232                 }
233 233                 j++;
234 234                 [leaveRowList addObject:detailModel];
235 235             }
236 236             STUDY_TBLList = [[NSMutableArray alloc]init];
237 237             STUDY_TBLList = [leaveRowList mutableCopy];
238 238             //再刷新
239 239            // [self tableView:tableView cellForRowAtIndexPath:indexPath];
240 240             [_titleTableView reloadData];
241 241             [_infoTableView reloadData];
242 242         };
243 243         return cell;
244 244     } else {//right
245 245         NSString *ident = @"InfoCell";
246 246         searchResultListCell *cell = [tableView dequeueReusableCellWithIdentifier:ident];
247 247         if (!cell) {
248 248             // cellResultList = [[[NSBundle mainBundle] loadNibNamed:@"InfoCell" owner:nil options:nil] lastObject];
249 249             cell = [[searchResultListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"InfoCell"];
250 250         }
251 251         if (indexPath.row%2 == 1) {
252 252             cell.backgroundColor = [UIColor colorWithRed:232.0/255.0 green:246.0/255.0 blue:255.0/255.0 alpha:1.0];
253 253         } else {
254 254             cell.backgroundColor = [UIColor whiteColor];
255 255         }
256 256         listPageModel * cellModellistPage=[STUDY_TBLList objectAtIndex:indexPath.row];
257 257         cell.selectionStyle = UITableViewCellSelectionStyleNone;
258 258         [cell setDataWithStrcellModel:cellModellistPage];
259 259         return cell;
260 260     }
261 261 }
262 262 
263 263 //MARK:- UIScrollViewDelegate
264 264 #pragma mark --两个scrollView联动
265 265 - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
266 266     if (scrollView == _titleTableView) {
267 267         [_infoTableView setContentOffset:CGPointMake(_infoTableView.contentOffset.x, _titleTableView.contentOffset.y)];
268 268     }
269 269     if (scrollView == _infoTableView) {
270 270         [_titleTableView setContentOffset:CGPointMake(0, _infoTableView.contentOffset.y)];
271 271     }
272 272 }
273 273 
274 274 #pragma mark --取消标题
275 275 // 取消标题
276 276 - (void)viewWillDisappear:(BOOL)animated {
277 277     [super viewWillDisappear:animated];
278 278     [self.navigationController setNavigationBarHidden:NO animated:animated];
279 279 }
280 280 // 取消标题
281 281 - (void)viewWillAppear:(BOOL)animated {
282 282     [super viewWillAppear:animated];
283 283     self.navigationController.navigationBar.hidden = YES;
284 284     [self.navigationController setNavigationBarHidden:YES animated:animated];
285 285 }
286 286 // 选择某一行更改list结果集
287 287 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
288 288     
289 289     NSLog(@"选中了%ld", (long)indexPath.row);
290 290     [tableView deselectRowAtIndexPath:indexPath animated:YES];
291 291     leaveRowList = [[NSMutableArray alloc]init];
292 292     int   j =0;
293 293     for (listPageModel *detailModel in STUDY_TBLList) {
294 294         if (j==indexPath.row) {
295 295             if ([detailModel.picture isEqual:@""]||[detailModel.picture isEqual:nil]||detailModel.picture ==nil) {
296 296                 detailModel.picture = @"toppan_duihao";
297 297             }else{
298 298                 detailModel.picture = @"";
299 299             }
300 300         }
301 301         j++;
302 302         [leaveRowList addObject:detailModel];
303 303     }
304 304     STUDY_TBLList = [[NSMutableArray alloc]init];
305 305     STUDY_TBLList = [leaveRowList mutableCopy];
306 306     //再刷新
307 307     [_titleTableView reloadData];
308 308     [_infoTableView reloadData];
309 309 }
310 310 
311 311 @end

一下变成可滑动样式

 

技术分享

技术分享

 

ios 横向滑动

标签:nsbundle   uila   2017年   opp   i++   reload   get   etc   express   

原文地址:http://www.cnblogs.com/lanmaokomi/p/7814262.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!