[Code Note] selection of reminder time and code note reminder
I ,.
2. Engineering Drawing.
3. Code.
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 *) bundle :( NSBundle *) handle {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 = @ "reminder time"; // UITableView remindTable = [[UITableView alloc] initWithFrame: CGRectMake (0, 1,320, self. view. bounds. size. height)]; [remindTable setSeparatorStyle: Custom]; [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 failed: cellIdentifier]; if (cell = nil) {cell = [[UITableViewCell alloc] initWithStyle: descrireuseidentifier: cellIdentifier];} textArray = [[NSArray alloc] initWithObjects: @ "NONE", @ "5 minutes ago", @ "15 minutes", @ "30 minutes ago ", @ "1 hour ago", @ "two hours ago", @ "1 day ago", @ "2 days ago", @ "Event Date", nil]; cell. textLabel. text = [textArray objectAtIndex: indexPath. row]; cell. textLabel. textColor = [UIColor orangeColor]; // split line 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]; // check the image 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 .}