一,效果图。

二,工程图。

三,代码。

RootViewController.h

  1. #import <UIKit/UIKit.h>
  2.  
  3. @interface RootViewController : UIViewController
  4. <UITableViewDataSource,UITableViewDelegate>
  5. {
  6. UITableView *remindTable;
  7. int lastIndex;
  8. int nowIndex;
  9. NSArray *textArray;
  10. }
  11.  
  12. @end

RootViewController.m

  1. #import "RootViewController.h"
  2.  
  3. @interface RootViewController ()
  4.  
  5. @end
  6.  
  7. @implementation RootViewController
  8.  
  9. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  10. {
  11. self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  12. if (self) {
  13. // Custom initialization
  14. }
  15. return self;
  16. }
  17.  
  18. - (void)viewDidLoad
  19. {
  20. [super viewDidLoad];
  21. // Do any additional setup after loading the view.
  22.  
  23. self.title=@"提醒时间";
  24.  
  25. //UITableView
  26. remindTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 1, 320, self.view.bounds.size.height)];
  27. [remindTable setSeparatorStyle:UITableViewCellSeparatorStyleNone];
  28. [remindTable setScrollEnabled:YES];
  29. [remindTable setDataSource:self];
  30. [remindTable setDelegate:self];
  31. [self.view addSubview:remindTable];
  32.  
  33. }
  34. #pragma -mark -UITableView Delegate
  35. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  36. {
  37. return 1;
  38. }
  39. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  40. {
  41. return 9;
  42. }
  43. - (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  44. {
  45. static NSString *cellIdentifier = @"Cell";
  46. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
  47. if (cell == nil) {
  48. cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  49. }
  50.  
  51. textArray = [[NSArray alloc]initWithObjects:@"无",@"5分钟前",@"15分钟",@"30分钟前",@"1小时前",@"两小时前",@"1天前",@"2天前",@"事件发生日",nil];
  52. cell.textLabel.text = [textArray objectAtIndex:indexPath.row];
  53. cell.textLabel.textColor = [UIColor orangeColor];
  54.  
  55. //分割线
  56. UIImage *line = [UIImage imageNamed:@"line.png"];
  57. UIImageView *lineView = [[UIImageView alloc]initWithFrame:CGRectMake(5,cell.contentView.frame.size.height-1 , 310, 1)];
  58. [lineView setImage:line];
  59. [cell.contentView addSubview:lineView];
  60.  
  61. //勾的图片
  62. UIImage *check = [UIImage imageNamed:@"gou.png"];
  63. UIImageView *checkView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, check.size.width/2, check.size.height/2)];
  64. [checkView setImage:check];
  65. if (indexPath.row == nowIndex) {
  66. cell.accessoryView = checkView;
  67. }
  68. else if (indexPath.row == lastIndex){
  69. cell.accessoryView = UITableViewCellAccessoryNone;
  70. }
  71. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  72. return cell;
  73. }
  74. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  75. {
  76. lastIndex = nowIndex;
  77. nowIndex = (int)indexPath.row;
  78.  
  79. NSLog(@"====%d",nowIndex);
  80. NSLog(@"----%d",lastIndex);
  81. [remindTable reloadData];
  82. }
  83.  
  84. - (void)didReceiveMemoryWarning
  85. {
  86. [super didReceiveMemoryWarning];
  87. // Dispose of any resources that can be recreated.
  88. }

【代码笔记】iOS-提醒时间的选择的更多相关文章

  1. 【代码笔记】iOS-点击出现选择框

    一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...

  2. 【代码笔记】iOS-忘记密码选择整体button

    一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @class BECheckBox; @interface ...

  3. 【hadoop代码笔记】hadoop作业提交之汇总

    一.概述 在本篇博文中,试图通过代码了解hadoop job执行的整个流程.即用户提交的mapreduce的jar文件.输入提交到hadoop的集群,并在集群中运行.重点在代码的角度描述整个流程,有些 ...

  4. 笔记-iOS 视图控制器转场详解(上)

    这是一篇长文,详细讲解了视图控制器转场的方方面面,配有详细的示意图和代码,为了使得文章在微信公众号中易于阅读,seedante 辛苦将大量长篇代码用截图的方式呈现,另外作者也在 Github 上附上了 ...

  5. IOS开发笔记 IOS如何访问通讯录

    IOS开发笔记  IOS如何访问通讯录 其实我是反对这类的需求,你说你读我的隐私,我肯定不愿意的. 幸好ios6.0 以后给了个权限控制.当打开app的时候你可以选择拒绝. 实现方法: [plain] ...

  6. iOS关于时间的处理

    转自:iOS关于时间的处理 做App避免不了要和时间打交道,关于时间的处理,里面有不少门道,远不是一行API调用,获取当前系统时间这么简单.我们需要了解与时间相关的各种API之间的差别,再因场景而异去 ...

  7. 极客时间 Mysql实战45讲 07讲行锁功过:怎么减少行锁对性能的影响笔记 极客时间

    极客时间 Mysql实战45讲 07讲行锁功过:怎么减少行锁对性能的影响笔记 极客时间极客时间 Mysql实战45讲 07讲行锁功过:怎么减少行锁对性能的影响笔记 极客时间 笔记体会: 方案一,事务相 ...

  8. 原生js日期时间插件鼠标点击文本框弹出日期时间表格选择日期时间

    原文出处 (这是我从互联网上搜来的,感觉能满足各方面的需求.个人感觉挺不错的,所以后期修改了一下向大家推荐!) 效果图: html代码: <!DOCTYPE html PUBLIC " ...

  9. <Python Text Processing with NLTK 2.0 Cookbook>代码笔记

    如下是<Python Text Processing with NLTK 2.0 Cookbook>一书部分章节的代码笔记. Tokenizing text into sentences ...

随机推荐

  1. 控件使用经验-MVP模式+控件封装

    项目背景 几年前参与了一个面向学校的人事管理软件的开发,基于WinForm平台.今天主要想谈一谈其中关于控件的使用经验.这个项目我们大量使用了第三方控件.由于这个产品的生命周期很长,我们在设计时要考虑 ...

  2. HoverTree系统源码介绍

    HoverTree是一个开源asp.net系统.系统的效果请到:http://hovertree.com体验. 源码描述:一.源码特点采用典型的三层架构进行开发,实现了留言板的功能,后台管理,留言审核 ...

  3. 【UWP】FlipView绑定ItemsSource,Selectedindex的问题

    最近在做列表头部的Carousel展示,Carousel使用的是FlipView展示,另外使用ListBox显示当前页,如下图 我们先设置一个绑定的数据源 public class GlobalRes ...

  4. 注册asp.net 4.0 到iis

    如果没有按照正常的先装iis后装.net的顺序,可以使用此命令重新注册一下: 32位的Windows:------------------------------------------------- ...

  5. 最小生成树---Kruskal/Prime算法

    1.Kruskal算法 图的存贮采用边集数组或邻接矩阵,权值相等的边在数组中排列次序可任意,边较多的不很实用,浪费时间,适合稀疏图.      方法:将图中边按其权值由小到大的次序顺序选取,若选边后不 ...

  6. 【Java每日一题】20161024

    20161021问题解析请点击今日问题下方的"[Java每日一题]20161024"查看 package Oct2016; public class Ques1024 { publ ...

  7. 基于Erlang VM的函数式编程语言Elixir

    Elixir官网:http://elixir-lang.org/ Elixir是一种函数式动态语言,用于构建可伸缩.易维护的应用程序. Elixir是基于Erlang VM的,其广为人知的特点是运行低 ...

  8. 利用Yii框架中的collections体验PHP类型化编程

    注:20150514 看过 惠新宸 关于PHP7的PPT后,看到了这一特性将被支持. Scalar Type Declarations function foo(int num) function ...

  9. PyCharm不能自动import解决方法_PyCharm cannot auto import package troubleshooting

    本人起初是用Eclipse+Pydev学习python的,其实也觉得挺好用.不过后来因为同事推荐去试了下PyCharm,就一发不可收拾的爱上了. 严格来说,题目上的问题其实对于很多人都不算是问题,但是 ...

  10. Struts 2.3.24源码解析+Struts2拦截参数,处理请求,返回到前台过程详析

    Struts2官网:http://struts.apache.org/ 目前最新版本:Struts 2.3.24 Struts1已经完全被淘汰了,而Struts2是借鉴了webwork的设计理念而设计 ...