Permalink
Browse files

Added support for clearsSelectionOnViewWillAppear in TTTableViewContr…

…oller (like in UITableViewController).
  • Loading branch information...
1 parent 6fecb7e commit add7f65498922a6467ede0e6964657ca8d2a7032 @jeanregisser jeanregisser committed Jun 18, 2010
Showing with 12 additions and 1 deletion.
  1. +7 −0 src/Three20UI/Headers/TTTableViewController.h
  2. +5 −1 src/Three20UI/Sources/TTTableViewController.m
@@ -39,6 +39,7 @@
BOOL _variableHeightRows;
BOOL _showTableShadows;
+ BOOL _clearsSelectionOnViewWillAppear;
id<TTTableViewDataSource> _dataSource;
id<UITableViewDelegate> _tableDelegate;
@@ -89,6 +90,12 @@
@property (nonatomic) BOOL showTableShadows;
/**
+ * A Boolean value indicating if the controller clears the selection when the table appears.
+ * Default is YES.
+ */
+@property(nonatomic) BOOL clearsSelectionOnViewWillAppear;
+
+/**
* Initializes and returns a controller having the given style.
*/
- (id)initWithStyle:(UITableViewStyle)style;
@@ -61,6 +61,7 @@ @implementation TTTableViewController
@synthesize tableViewStyle = _tableViewStyle;
@synthesize variableHeightRows = _variableHeightRows;
@synthesize showTableShadows = _showTableShadows;
+@synthesize clearsSelectionOnViewWillAppear = _clearsSelectionOnViewWillAppear;
@synthesize dataSource = _dataSource;
@@ -69,6 +70,7 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
_lastInterfaceOrientation = self.interfaceOrientation;
_tableViewStyle = UITableViewStylePlain;
+ _clearsSelectionOnViewWillAppear = YES;
}
return self;
@@ -266,7 +268,9 @@ - (void)viewWillAppear:(BOOL)animated {
tableView.showShadows = _showTableShadows;
}
- [_tableView deselectRowAtIndexPath:[_tableView indexPathForSelectedRow] animated:animated];
+ if (_clearsSelectionOnViewWillAppear) {
+ [_tableView deselectRowAtIndexPath:[_tableView indexPathForSelectedRow] animated:animated];
+ }
}

0 comments on commit add7f65

Please sign in to comment.