【代码笔记】iOS-提醒时间的选择
一,效果图。
二,工程图。
三,代码。
RootViewController.h

- #import <UIKit/UIKit.h>
- @interface RootViewController : UIViewController
- <UITableViewDataSource,UITableViewDelegate>
- {
- UITableView *remindTable;
- int lastIndex;
- int nowIndex;
- NSArray *textArray;
- }
- @end

RootViewController.m

- #import "RootViewController.h"
- @interface RootViewController ()
- @end
- @implementation RootViewController
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- // Custom initialization
- }
- return self;
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.title=@"提醒时间";
- //UITableView
- remindTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 1, 320, self.view.bounds.size.height)];
- [remindTable setSeparatorStyle:UITableViewCellSeparatorStyleNone];
- [remindTable setScrollEnabled:YES];
- [remindTable setDataSource:self];
- [remindTable setDelegate:self];
- [self.view addSubview:remindTable];
- }
- #pragma -mark -UITableView Delegate
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return 9;
- }
- - (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *cellIdentifier = @"Cell";
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
- if (cell == nil) {
- cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
- }
- textArray = [[NSArray alloc]initWithObjects:@"无",@"5分钟前",@"15分钟",@"30分钟前",@"1小时前",@"两小时前",@"1天前",@"2天前",@"事件发生日",nil];
- cell.textLabel.text = [textArray objectAtIndex:indexPath.row];
- cell.textLabel.textColor = [UIColor orangeColor];
- //分割线
- UIImage *line = [UIImage imageNamed:@"line.png"];
- UIImageView *lineView = [[UIImageView alloc]initWithFrame:CGRectMake(5,cell.contentView.frame.size.height-1 , 310, 1)];
- [lineView setImage:line];
- [cell.contentView addSubview:lineView];
- //勾的图片
- UIImage *check = [UIImage imageNamed:@"gou.png"];
- UIImageView *checkView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, check.size.width/2, check.size.height/2)];
- [checkView setImage:check];
- if (indexPath.row == nowIndex) {
- cell.accessoryView = checkView;
- }
- else if (indexPath.row == lastIndex){
- cell.accessoryView = UITableViewCellAccessoryNone;
- }
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- lastIndex = nowIndex;
- nowIndex = (int)indexPath.row;
- NSLog(@"====%d",nowIndex);
- NSLog(@"----%d",lastIndex);
- [remindTable reloadData];
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }

【代码笔记】iOS-提醒时间的选择的更多相关文章
- 【代码笔记】iOS-点击出现选择框
一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...
- 【代码笔记】iOS-忘记密码选择整体button
一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @class BECheckBox; @interface ...
- 【hadoop代码笔记】hadoop作业提交之汇总
一.概述 在本篇博文中,试图通过代码了解hadoop job执行的整个流程.即用户提交的mapreduce的jar文件.输入提交到hadoop的集群,并在集群中运行.重点在代码的角度描述整个流程,有些 ...
- 笔记-iOS 视图控制器转场详解(上)
这是一篇长文,详细讲解了视图控制器转场的方方面面,配有详细的示意图和代码,为了使得文章在微信公众号中易于阅读,seedante 辛苦将大量长篇代码用截图的方式呈现,另外作者也在 Github 上附上了 ...
- IOS开发笔记 IOS如何访问通讯录
IOS开发笔记 IOS如何访问通讯录 其实我是反对这类的需求,你说你读我的隐私,我肯定不愿意的. 幸好ios6.0 以后给了个权限控制.当打开app的时候你可以选择拒绝. 实现方法: [plain] ...
- iOS关于时间的处理
转自:iOS关于时间的处理 做App避免不了要和时间打交道,关于时间的处理,里面有不少门道,远不是一行API调用,获取当前系统时间这么简单.我们需要了解与时间相关的各种API之间的差别,再因场景而异去 ...
- 极客时间 Mysql实战45讲 07讲行锁功过:怎么减少行锁对性能的影响笔记 极客时间
极客时间 Mysql实战45讲 07讲行锁功过:怎么减少行锁对性能的影响笔记 极客时间极客时间 Mysql实战45讲 07讲行锁功过:怎么减少行锁对性能的影响笔记 极客时间 笔记体会: 方案一,事务相 ...
- 原生js日期时间插件鼠标点击文本框弹出日期时间表格选择日期时间
原文出处 (这是我从互联网上搜来的,感觉能满足各方面的需求.个人感觉挺不错的,所以后期修改了一下向大家推荐!) 效果图: html代码: <!DOCTYPE html PUBLIC " ...
- <Python Text Processing with NLTK 2.0 Cookbook>代码笔记
如下是<Python Text Processing with NLTK 2.0 Cookbook>一书部分章节的代码笔记. Tokenizing text into sentences ...
随机推荐
- 控件使用经验-MVP模式+控件封装
项目背景 几年前参与了一个面向学校的人事管理软件的开发,基于WinForm平台.今天主要想谈一谈其中关于控件的使用经验.这个项目我们大量使用了第三方控件.由于这个产品的生命周期很长,我们在设计时要考虑 ...
- HoverTree系统源码介绍
HoverTree是一个开源asp.net系统.系统的效果请到:http://hovertree.com体验. 源码描述:一.源码特点采用典型的三层架构进行开发,实现了留言板的功能,后台管理,留言审核 ...
- 【UWP】FlipView绑定ItemsSource,Selectedindex的问题
最近在做列表头部的Carousel展示,Carousel使用的是FlipView展示,另外使用ListBox显示当前页,如下图 我们先设置一个绑定的数据源 public class GlobalRes ...
- 注册asp.net 4.0 到iis
如果没有按照正常的先装iis后装.net的顺序,可以使用此命令重新注册一下: 32位的Windows:------------------------------------------------- ...
- 最小生成树---Kruskal/Prime算法
1.Kruskal算法 图的存贮采用边集数组或邻接矩阵,权值相等的边在数组中排列次序可任意,边较多的不很实用,浪费时间,适合稀疏图. 方法:将图中边按其权值由小到大的次序顺序选取,若选边后不 ...
- 【Java每日一题】20161024
20161021问题解析请点击今日问题下方的"[Java每日一题]20161024"查看 package Oct2016; public class Ques1024 { publ ...
- 基于Erlang VM的函数式编程语言Elixir
Elixir官网:http://elixir-lang.org/ Elixir是一种函数式动态语言,用于构建可伸缩.易维护的应用程序. Elixir是基于Erlang VM的,其广为人知的特点是运行低 ...
- 利用Yii框架中的collections体验PHP类型化编程
注:20150514 看过 惠新宸 关于PHP7的PPT后,看到了这一特性将被支持. Scalar Type Declarations function foo(int num) function ...
- PyCharm不能自动import解决方法_PyCharm cannot auto import package troubleshooting
本人起初是用Eclipse+Pydev学习python的,其实也觉得挺好用.不过后来因为同事推荐去试了下PyCharm,就一发不可收拾的爱上了. 严格来说,题目上的问题其实对于很多人都不算是问题,但是 ...
- Struts 2.3.24源码解析+Struts2拦截参数,处理请求,返回到前台过程详析
Struts2官网:http://struts.apache.org/ 目前最新版本:Struts 2.3.24 Struts1已经完全被淘汰了,而Struts2是借鉴了webwork的设计理念而设计 ...