This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation MyTableViewCell | |
- (IBAction)checkboxPressed:(UIButton *)checkbox event:(UIEvent *)event { | |
// Send onwards up the responder chain with the cell as sender | |
[UIApplication.sharedApplication sendAction:@selector(cellCheckboxPressed:) | |
to:nil | |
from:self | |
event:event]; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@protocol MyTableViewCellDelegate | |
- (void)tableCellCheckboxPressed:(MyTableViewCell *)cell; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation MyTableViewCell | |
- (IBAction)checkboxPressed:(UIButton *)checkbox { | |
// Dispatch onwards to controller with extra info | |
// so it can easily identify which task/cell/row | |
// is being acted on. | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation MyTableViewController | |
- (IBAction)checkboxPressed:(UIButton *)button { | |
// Figure out which row this checkbox belongs to | |
id aView = button.superview; | |
while (![aView isKindOfClass:UITableViewCell.class]) { | |
aView = [aView superview]; | |
} | |
NSIndexPath *row = [self.tableView indexPathForCell:aView]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewWillAppear:(BOOL)animated | |
{ | |
[super viewWillAppear:animated]; | |
BOOL inMultipleSelectionMode = (self.tableView.editing ? | |
self.tableView.allowsMultipleSelectionDuringEditing : | |
self.tableView.allowsMultipleSelection); | |
NSIndexPath *selectedRowIndexPath = [self.tableView indexPathForSelectedRow]; | |
if (selectedRowIndexPath && !inMultipleSelectionMode) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewWillDisappear:(BOOL)animated { | |
[super viewWillDisappear:animated]; | |
UIViewController *root = self.presentingViewController.presentedViewController; | |
if (root.isBeingDismissed) { | |
[self.view endEditing:YES]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewWillDisappear:(BOOL)animated { | |
[super viewWillDisappear:animated]; | |
if (self.isBeingDismissed) { | |
[self.view endEditing:YES]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cell.detailTextLabel.text = updatedText; | |
[cell setNeedsLayout]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | |
MyViewController *destination = segue.destinationViewController; | |
// Configure view controller | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | |
UINavigationController *navController = segue.destinationViewController; | |
MyViewController *realDestination = navController.viewControllers[0]; | |
// Configure view controller | |
} |