[Code Note] selection of reminder time and code note reminder

Source: Internet
Author: User

[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 .}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.