1. 点击“cell”推出对应的界面

  1.1 新建group,名为:Setting

    路径:MYLottery(我的彩票)->Controller

  1.2 新建Cocoa Touch Class,名为:HMRedeemController

    路径:MYLottery(我的彩票)->Controller->Setting->

       Cocoa Touch Class:(Class:HMRedeemController;Subclass of:UIViewController;Language:Objective-C)

  1.3 在“HMRedeemController.m”的“viewDidLoad”方法中设置“View Controller”的背景为紫色,代码如下:

  1. - (void)viewDidLoad
  2. {
  3. self.view.backgroundColor = [UIColor purpleColor];
  4. }

  1.4 在“HMSettingController.m”创建点击“cell”调用方法,代码如下:

  1. //点击 cell 调用
  2. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  3. {
  4. //获取组
  5. NSDictionary *group = self.groups[indexPath.section];
  6. //获取组所有的 cell
  7. NSArray *items = group[@"items"];
  8. //获取 cell 的信息
  9. NSDictionary *item = items[indexPath.row];
  10.  
  11. if (item[@"targetVC"] && [item[@"targetVC"] length] > ]) {
  12.  
  13. //获取字符串类型的目标
  14. NSString *targetVC = item[@"targetVC"];
  15. //转换为 Class 的类型
  16. Class Clz = NSClassFromString(targetVC);
  17. //Class 的类型的对象
  18. UIViewController *vc = [[Clz alloc] init];
  19.  
  20. if ([vc isKindOfClass:[HMSettingController class]]) {
  21. //如果是 setting 类型,需要传入一个 plistName
  22. HMSettingController *setting = (HMSettingController *)vc;
  23. setting.plishName = item[@"plistName"];
  24. }
  25.  
  26. //设置 title
  27. vc.navigationItem.title = item[@"title"];
  28. //跳转
  29. [self.navigationControler pushViewController:vc animated:YES];
  30. }
  31. }

2. 点击“推送和提醒”推出对应的界面

  2.1 修改“plist”获取方法

    2.1.1 在“HMSettingController.h”申明“plistName”属性,

      代码如下:@property (nonatomic, copy) NSString *plistName;

    2.1.2 在“HMSettingController.m”修改“plist”获取方法

      原码:NSString *path = [[NSBundle mainBundle] pathForResource:@“Setting” ofType:@"plist"];

      修改:NSString *path = [[NSBundle mainBundle] pathForResource:self.plistName ofType:@"plist"];

    2.1.3 在“HMMyLotteryController.m”的“settingClick”方法添加“plist”获取属性

      代码如下:setting.plistName = @"Setting";

  2.2 重写“init”方法

    2.2.1 在“HMSettingController.m”新建重写“init”方法

  1. - (instancetype)init
  2. {
  3. return [super initWithStyle:UITableViewStyleGrouped];
  4. }
  5.  
  6. - (instancetype)initWithStyle:(UITableViewStyle)style
  7. {
  8. return [super initWithStyle:UITableViewStyleGrouped];
  9. }

    2.1.2 在“HMMyLotteryController.m”修改“Table View”的“init”方法

      原码:HMSettingController *setting = [[HMSettingController alloc] initWithStyle:UITableViewStyleGrouped];

      修改:HMSettingController *setting = [[HMSettingController alloc] init];

  2.3 新建Property List,名为:SettingPush

    路径:MYLottery(我的彩票)->Other

  2.4 在“HMSettingController.m”修改加载“cell”图片属性

    原码:cell.imageView.image = [UIImage imageNamed:item[@"icon"]];

    修改:if (item[@"icon"] && [item[@"icon"] length] > 0) {

        //设置 cell 图片

        cell.imageView.image = [UIImage imageNamed:item[@"icon"]];

       }

  2.5 将“HMSettingController.m”类中的“viewDidLoad”方法中的“self.navigationControler.title = @"设置";”

    剪切到“HMMyLotteryController.m”类中的“settingClick”方法中

3. “推送和提醒”的“开奖推送”界面

  3.1 新建Property List,名为:SettingPush01

    路径:MYLottery(我的彩票)->Other

  3.2 在“HMSettingController.m”创建 cell 返回类型,代码如下:

  1. //根据传入的 cell 类型,返回需要创建的 cell 的类型
  2. - (UITableViewCellStyle)loadCellStyleWithItem:(NSDictionary *)item
  3. {
  4. if ([item[@"cellType"] isEqualToString:@"UITableViewCellStyleSubtitle"]) {
  5. return UITableViewCellStyleSubtitle;
  6. }
  7. else if ([item[@"cellType"] isEqualToString:@"UITableViewCellStyleValue1"]) {
  8. return UITableViewCellStyleValue1;
  9. }
  10. else if ([item[@"cellType"] isEqualToString:@"UITableViewCellStyleValue2"]) {
  11. return UITableViewCellStyleValue2;
  12. }
  13. else {
  14. return UITableViewCellStyleDefault;
  15. }
  16. }

  3.3 在“HMSettingController.m”类中的“UITableViewCell”方法中修改 cell 创建类型方式

    原码:cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid];

    修改:cell = [[UITableViewCell alloc] initWithStyle:[self loadCellStyleWithItem:item] reuseIdentifier:cellid];

  3.4 在“HMSettingController.m”类中的“UITableViewCell”添加 cell 的子标题

    代码如下:cell.detailTextLabel.text = item[@"subTitle"];
4. 封装 cell

  4.1 新建Cocoa Touch Class,名为:HMSettingCell

    路径:MYLottery(我的彩票)->View->

       Cocoa Touch Class:(Class:HMSettingCell;Subclass of:UITableViewCell;Language:Objective-C)

  4.2 在“HMSettingCell.h”申明"item"字典和“settingCellWithTableView”类方法,

    代码如下:

  1. @property (nonatomic, strong) NSDictionary *item;
  2.  
  3. + (instancetype)settingCellWithTableView:(UITableView *)tableView andItem:(NSDictionary *)item;

  4.3 在“HMSettingCell.m”实现“settingCellWithTableView”类方法,

    将“HMMyLotteryController.m”相关代码剪切到该文件修改,代码如下:

  1. @implementation HMSettingCell
  2.  
  3. + (instancetype)settingCellWithTableView:(UITableView *)tableView andItem:(NSDictionary *)item
  4. {
  5. //static NSString *cellid = @"setting_cell";
  6. //cell 重用
  7. NSString *cellid = @"";
  8. if (item[@"cellType"] && [item[@"cellType"] length] > ) {
  9. cellid = item[@"cellType"];
  10. } else {
  11. cellid = @"setting_cell";
  12. }
  13.  
  14. //缓存池找
  15. HMSettingCell *cell = [tableView dequeueReusableCellWithIdentifier:cellid];
  16. if (!cell) {
  17. cell = [[HMSettingCell alloc] initWithStyle:[self loadCellStyleWithItem] reuseIdentifier:cellid];
  18. }
  19.  
  20. cell.item = item;
  21.  
  22. return cell;
  23. }
  24.  
  25. - (void)setItem:(NSDictionary *)item
  26. {
  27. _item = item;
  28.  
  29. //把数据放到 cell
  30.  
  31. //赋值
  32. if (item[@"icon"] && [item[@"icon"] length] > ) {
  33. self.imageView.image = [UIImage imageNamed:item[@"icon"]]; //设置图片
  34. }
  35. self.textLabel.text = item[@"title"]; //设置标题
  36. self.detailTextLabel.text = item[@"subTitle"]; //设置子标题
  37.  
  38. //根据字符创建生成对象
  39. NSString *accessoryType = item[@"accessoryType"]; //获取 UISwith 的字符串:@"UISwith"
  40. Class Clz = NSClassFromString(accessoryType); //获取 UISwith 的类型:UISwith
  41. UIView *obj = [[Clz alloc] init]; //获取 UISwith 类型的对象
  42.  
  43. //判断 obj 真实的类型
  44. if ([obj isKindOfClass:[UIImage class]]) {
  45. //设置 frame 图片
  46. UIImageView *imageView = (UIImageView *)obj;
  47. imageView.image = [UIImage imageNamed:item[@"accessoryContent"]];
  48. [imageView sizeToFit];
  49. }
  50.  
  51. self.accessoryType = obj; //设置 accessoryView
  52. }
  53.  
  54. //根据传入的 cell 类型,返回需要创建的 cell 的类型
  55. - (UITableViewCellStyle)loadCellStyleWithItem:(NSDictionary *)item
  56. {
  57. if ([item[@"cellType"] isEqualToString:@"UITableViewCellStyleSubtitle"]) {
  58. return UITableViewCellStyleSubtitle;
  59. }
  60. else if ([item[@"cellType"] isEqualToString:@"UITableViewCellStyleValue1"]) {
  61. return UITableViewCellStyleValue1;
  62. }
  63. else if ([item[@"cellType"] isEqualToString:@"UITableViewCellStyleValue2"]) {
  64. return UITableViewCellStyleValue2;
  65. }
  66. else {
  67. return UITableViewCellStyleDefault;
  68. }
  69. }
  70.  
  71. @end

5. “推送和提醒”的“比分直播推送”界面

  5.1 新建Cocoa Touch Class,名为:HMLiveController

    路径:MYLottery(我的彩票)->Controller->Setting->

       Cocoa Touch Class:(Class:HMLiveController;Subclass of:UISettingController;Language:Objective-C)

  5.2 配置“SettingPush.plish”

    Item 1->“plistName”:SettingPush02

    Item 1->“targetVC”:“HMLiveController”

  5.3 新建Property List,名为:SettingPush02

     路径:MYLottery(我的彩票)->Other

  5.4 设置“起始时间”和“结束时间”的时间字体为红色

    在“HMSettingCell.m”类的“setItem”方法中添加子标题颜色方法,代码如下:

  1. if ([item[@"isRed"] boolValue] && item[@"isRed"]) {
  2. self.detaiTextLabel.textColor = [UIColor redColor]; //设置子标题颜色
  3. }

  5.5 点击“起始时间”和“结束时间” cell 弹出文本框

    5.5.1 在“HMLiveController.m”中申明“datePlicker”的全局变量

      代码如下:@property (nonatomic, weak) UIDatePicker *datePicker;

    5.5.2 在“HMLiveController.m”中创建 cell 点击事件,代码如下:

  1. #import "UIView_Frame.h"
  2.  
  3. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  4. {
  5. //第一组不点
  6. if (indexPath.section == ) {
  7. return;
  8. }
  9.  
  10. //创建一个看不见的文本框
  11. UITextField *text = [[UITextField alloc] init];
  12.  
  13. //创建 cell
  14. UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
  15.  
  16. //添加到 cell 上
  17. [cell.contentView addSubview:text];
  18.  
  19. //创建 datePicker
  20. UIDatePicker.locale = [[UIDatePicker alloc] init];
  21. self.datePicker = datePicker;
  22.  
  23. //中文
  24. datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];
  25.  
  26. //时间模式
  27. datePicker.datePickerMode = UIDatePickerModeTime;
  28.  
  29. //设置文本框的 inputView
  30. text.inputView = datePicker;
  31.  
  32. //创建 toolbar
  33. UIToolbar * bar = [[UIToolbar alloc] init];
  34.  
  35. //设置 toolbar 的高度
  36. bar.h = ;
  37.  
  38. //创建三个 item
  39. //item - 取消
  40. UIBarButtonItem *cancelItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(cancelClick)];
  41. //item - 弹簧
  42. UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonItemStyleItemFlexibleSpace target:nil action:nil];
  43. //item - 完成
  44. UIBarButtonItem *doneItem = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStyleDone target:self action:@selector(doneClick)];
  45.  
  46. //设置 toolbar 的 item
  47. bar.items = @[cancelItem, item, doneItem];
  48.  
  49. //设置文本框的 imputAccessoryView
  50. text.inpushAccessoryView = bar;
  51.  
  52. //让文本框成为第一响应者
  53. [text becomeFirstResponder];
  54. }

    5.5.3 在“HMLiveController.m”中创建 toolbar 取消按钮的点击事件,代码如下:

  1. //收键盘
  2. - (void)cancelClick
  3. {
  4. [self.view endEditing:YES];
  5. }

    5.5.4 在“HMLiveController.m”中创建 toolbar 完成按钮的点击事件,代码如下:

  1. - (void)doneClick
  2. {
  3. //获取 datePicker 的时间
  4. NSDate *date = self.datePicker.date;
  5.  
  6. //创建格式化时间的对象
  7. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  8.  
  9. //设置格式化时间对象的格式
  10. formatter.dateFormat = @"HH:mm";
  11.  
  12. //把 date 转成 string
  13. NSString *time = [formatter stringFromFate:date];
  14.  
  15. //获取 indexPath
  16. NSIndexPath *path = [self.tableView indexPathForSelectedRow];
  17.  
  18. //获取 cell
  19. UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:path];
  20.  
  21. //修改时间
  22. cell.detaiTextLabel.text = time;
  23.  
  24. //收键盘
  25. [self cancelClick];
  26. }

网易彩票-我的彩票-设置-cell跳转界面的更多相关文章

  1. UITableView设置cell为不可选?

    本文选自StackOverflow(简称:SOF)精选问答汇总系列文章之一,本系列文章将为读者分享国外最优质的精彩问与答,供读者学习和了解国外最新技术.本文将为读者讲解UITableView如何设置单 ...

  2. IOS中设置cell的背景view和选中时的背景view 、设置cell最右边的指示器(比如箭头\文本标签)

    一.Cell的设置 1.设置cell的背景view和选中时的背景view UIImageView *bg = [[UIImageView alloc] init]; bg.image = [UIIma ...

  3. 设置 cell点击 背景色

    //设置 cell点击 背景色 cell.selectionStyle = UITableViewCellSelectionStyleDefault; cell.selectedBackgroundV ...

  4. IIS 7.5 使用URL Rewrite模块简单设置网页跳转

    原文 IIS 7.5 使用URL Rewrite模块简单设置网页跳转 我们都知道Apache可以在配置文件里方便的设置针对网页或网站的rewrite,但是最近接手了一组IIS服务器,发现这货简单的没有 ...

  5. cdnbest设置301跳转

     cdnbest设置301跳转  格式:^http://kangleweb.com/(.*)$   https://www.kangleweb.com/$1  下面是站点里所有域名都跳转到https ...

  6. collectionView代理方法快速设置cell大小上下左右间隔

    #define JianGe 25 #define GeShu 4 #define ScreenWidth ([UIScreen mainScreen].bounds.size.width) #def ...

  7. 设置cell高度的两种方法(label高度的可变引起cell高度可变的情况)

    第一种:(iOS8以后可用) 在Xib或stroyboard中(代码也可以) 利用AutoLayout设置好label的约束(比如可以设置四个边都距离屏幕50等方式,必须四个边都要固定好). 在代码部 ...

  8. POI对EXCEL的操作【重点:如何设置CELL格式为文本格式】

    实际开发过程中通常用到的就是从数据库导出EXCEL表格了,JXL可以这样做,其实POI也可以(关于JXL与POI的异同可访问我之前总结的文章),之前写过POI对七种文档(当然也包括EXCEL)的内容读 ...

  9. ios 设置cell的间距

    1.设置假的间距,我们在tableviewcell的contentView上添加一个view,比如让其距离上下左右的距离都是10:这个方法是最容易想到的: 2.用UIContentView来代替tab ...

随机推荐

  1. max_delay/min_delay和input_delay/output_delay

    今天在使用DC设置随路时钟的时候发现里两个比较容易混淆的设置:max_delay/min_delay和input_delay/output_delay. 1)max_delay/min_delay设置 ...

  2. layer弹出层不居中解决方案(转)

    @感谢参考文章 原文内容: 一.问题描述 用layer做操作结果提示时,发现如果页面超出屏幕的高度时,弹出的提示不是屏幕居中,而是在页面高度的中间,如果一个页面的高度比较大,就看不到提示了. 还有一种 ...

  3. 用python计算圆周率PI

    1.蒙特卡洛求圆周率 向区域内随即撒点 当点的数目足够多时,落在圆的点数目与在正方形点数目成正比 即圆的面积和正方形的面积成正比 可以得出计算圆周率的算法 DARTS=100000000   hits ...

  4. java调用本地播放器播放视频文件。调用本地播放器不能播放指定文件的说明。

    public class OpenExe extends HttpServlet { //打开本地播放器并播放视频 public static void openExe(String file) { ...

  5. linux 网络管理的三种方式

    修改网络IP的三种方式 1.修改配置文件 1.1dhcp自动获取 配置文件地址/etc/sysconfig/network-scripts TYPE=Ethernet  #类型=以太网 PROXY_M ...

  6. spring :Log4j各级别日志重复打印

    使用filter进行日志过滤 这个其实是Log4j自带的方案,也是推荐方案,不知道为什么网上的资料却很少提到这点. 把log4j.properties配置文件修改成如下: #root日志 log4j. ...

  7. 51ak带你看MYSQL5.7源码4:实现SQL黑名单功能

    博客迁移至: https://www.dboop.com/ 从事DBA工作多年 MYSQL源码也是头一次接触 尝试记录下自己看MYSQL5.7源码的历程 申明:个人Python编程很溜,但是C++还停 ...

  8. 20172306 2018-2019-2 《Java程序设计与数据结构》第六周学习总结

    20172306 2018-2019-2 <Java程序设计与数据结构>第六周学习总结 教材学习内容总结 概述(了解一下树的一些概念) 树是一种非线性结构.树由一个包含结点和边的集构成,其 ...

  9. python基础之Day21

    对象整合了操作数据的方法 1.init方法 调用类时自动触发,为对象初始化自己独有的特征 class people: def __init__(self,name,age,sex): self.nam ...

  10. Finance公式说明

    公式说明 代码 说明 Y 期末余额 JY 期末借方余额 DY 期末贷方余额 C 期初余额 JC 期初借方余额 DC 期初贷方余额 SY 本期实际发生额 SL 利润表本年实际发生额 SY 期末余额 SJ ...