【代码笔记】iOS-提醒时间的选择
来源:互联网 发布:java并发编程的书 编辑:程序博客网 时间:2024/05/16 12:32
一,效果图。
二,工程图。
三,代码。
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.}
0 0
- 【代码笔记】iOS-提醒时间的选择
- 【代码笔记】iOS-时间选择框
- 【代码笔记】iOS-获得现在的时间
- 【代码笔记】iOS-获得现在的时间
- 【代码笔记】iOS-两个时间字符串的比较
- 【代码笔记】iOS-获取现在的日历时间
- 【代码笔记】iOS-单项选择框
- 【代码笔记】iOS-点击出现选择框
- 【代码笔记】iOS-自定义选择框
- 【代码笔记】iOS-和当前时间比较
- 选择样式的日期时间js代码
- iOS客户端的升级提醒
- iOS 的更新提醒教程
- [随 笔]iOS提醒笔记
- 【代码笔记】iOS-忘记密码选择整体button
- 【代码笔记】iOS-先选择城市,然后,跳转Tabbar
- 【代码笔记】iOS-自定义选择框(高底强弱)
- 【代码笔记】iOS-获取系统完成任务所需的后台时间
- js年月日三级联动
- 001-递归
- 冒号课堂读书笔记(1)
- Core Data使用
- 月薪3万的程序员都避开了哪些坑
- 【代码笔记】iOS-提醒时间的选择
- com.showself.utils.DLog
- C#-using用法详解
- 【leetcode】第14题:Longest Common Prefix
- sap 实战 table
- DOS窗口如何实现复制粘贴
- 36个Android开发常用代码片段
- 学习IIS服务器勿使用CGI程式
- 进程与线程栈大小的调整(vsz 虚拟内存大小)