大佬教程收集整理的这篇文章主要介绍了ios – 通过Apple的ToDoList应用程序教程,项目点击不会正确添加“已完成”复选标记.,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
XYZToDoListViewController.m:
// // XYZToDoListViewController.m // ToDoList // // Created by Andrew Ghobrial on 2/15/14. // // #import "XYZToDoListViewController.h" #import "XYZToDoItem.h" @interface XYZToDoListViewController () @property NSMutableArray *toDoItems; @end @implementation XYZToDoListViewController - (void)loadInitialData { XYZToDoItem *item1 = [[XYZToDoItem alloc] init]; item1.itemname = @"Buy milk"; [self.toDoItems addObject:item1]; XYZToDoItem *item2 = [[XYZToDoItem alloc] init]; item2.itemname = @"Buy eggs"; [self.toDoItems addObject:item2]; XYZToDoItem *item3 = [[XYZToDoItem alloc] init]; item3.itemname = @"Read a book"; [self.toDoItems addObject:item3]; } - (IBACtion)unwindToList:(UIStoryboardSegue *)segue { } - (id)initWithStyle:(UITableViewStylE)style { self = [super initWithStyle:style]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; self.toDoItems = [[NSMutableArray alloc] init]; [self loadInitialData]; // Uncomment the following line to preserve SELEction between presentations. // self.cleaRSSelectionOnViewWillAppear = NO; // Uncomment the following line to display an Edit button in the navigation bar for this view controller. // self.navigationItem.rightBarButtonItem = self.editButtonItem; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [self.toDoItems count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowATindexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"ListPrototypeCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; XYZToDoItem *toDoItem = [self.toDoItems objectATindex:indexPath.row]; cell.textLabel.text = toDoItem.itemname; if (toDoItem.completed) { cell.accessoryType = UITableViewCellAccessorycheckmark; } else { cell.accessoryType = UITableViewCellAccessoryNone; } return cell; } /* // Override to support conditional ediTing of the table view. - (BOOL)tableView:(UITableView *)tableView canEditRowATindexPath:(NSIndexPath *)indexPath { // Return NO if you do not want the specified item to be editable. return YES; } */ /* // Override to support ediTing the table view. - (void)tableView:(UITableView *)tableView commitEdiTingStyle:(UITableViewCellEdiTingStylE)ediTingStyle forRowATindexPath:(NSIndexPath *)indexPath { if (ediTingStyle == UITableViewCellEdiTingStyleDelete) { // delete the row from the data source [tableView deleteRowsATindexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; } else if (ediTingStyle == UITableViewCellEdiTingStyleInsert) { // Create a new instance of the appropriate class,insert it into the array,and add a new row to the table view } } */ /* // Override to support rearranging the table view. - (void)tableView:(UITableView *)tableView moveRowATindexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { } */ /* // Override to support conditional rearranging of the table view. - (BOOL)tableView:(UITableView *)tableView canMoveRowATindexPath:(NSIndexPath *)indexPath { // Return NO if you do not want the item to be re-orderable. return YES; } */ /* #pragma mark - Navigation // In a story board-based application,you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue desTinationViewController]. // Pass the SELEcted object to the new view controller. } */ #pragma mark - Table view delegate - (void)tableView:(UITableView *)tableView didDeSELEctRowATindexPath:(NSIndexPath *)indexPath { [tableView deSELEctRowATindexPath:indexPath animated:NO]; XYZToDoItem *tappedItem = [self.toDoItems objectATindex:indexPath.row]; tappedItem.completed = !tappedItem.completed; [tableView reloadRowsATindexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationNone]; } @end
以上是大佬教程为你收集整理的ios – 通过Apple的ToDoList应用程序教程,项目点击不会正确添加“已完成”复选标记.全部内容,希望文章能够帮你解决ios – 通过Apple的ToDoList应用程序教程,项目点击不会正确添加“已完成”复选标记.所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。