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解决方法
- (voID)tableVIEw:(UItableVIEw *)tableVIEw dIDdeselectRowAtIndexPath:(NSIndexPath *)indexPath
应该
- (voID)tableVIEw:(UItableVIEw *)tableVIEw dIDSelectRowAtIndexPath:(NSIndexPath *)indexPath
请注意,您已取消选择但需要选择
@H_404_34@ 总结以上是内存溢出为你收集整理的ios – 通过Apple的ToDoList应用程序教程,项目点击不会正确添加“已完成”复选标记.全部内容,希望文章能够帮你解决ios – 通过Apple的ToDoList应用程序教程,项目点击不会正确添加“已完成”复选标记.所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)