I get that you need to use the following method and return what you want the new title to be as an NSString. However I don’t know where to put this method. Where is it normally placed?
- (NSString *)tableView:(UITableView *)tableView
titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
return @"Close";
}
I’ve tried it in my TableViewController and it doesn’t work:
interface
#import <Three20/Three20.h>
@interface PositionsController : TTTableViewController {
}
@end
implementation
#import "PositionsController.h"
#import "NetworkController.h"
#import "PositionsDataSource.h"
@implementation PositionsController
- (id) init {
if (self = [super init]) {
self.variableHeightRows = NO;
}
return self;
}
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
return @"Close";
}
@end
I won’t put all the code in there, nevertheless everything functions as it should but I still get Delete as the title for my button and not Close.
Three20 Library Revised Working Code
The problem I was having is that I was using the TTTableViewDragRefreshDelegate for my UITableView’s delegate. I was doing so via the following method:
- (id<UITableViewDelegate>)createDelegate {
return [[[TTTableViewDragRefreshDelegate alloc] initWithController:self] autorelease];
}
That’s all well and good but if you want to override a method that the UITableViewDelegate calls, like what I was trying to do here, then you need to create your own delegation class that inherits TTTableViewDragRefreshDelegate and put your method overrides in that class. Here is what my working code looks like:
Revised PositionsController.m createDelegate method
- (id<UITableViewDelegate>)createDelegate {
return [[[PositionsTableDelegate alloc] initWithController:self] autorelease];
}
PositionsTableDelegate.h
#import <Three20/Three20.h>
@interface PositionsTableDelegate : TTTableViewDragRefreshDelegate <UITableViewDelegate> {
}
@end
PositionsTableDelegate.m
#import "PositionsTableDelegate.h"
@implementation PositionsTableDelegate
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
return @"Close";
}
@end
This is a delegate method of UITableView. You need to implement it in the class which instance is set as the delegate of your TableView.
Try to set the
delegate-property of the TableView to the instance ofPositionsController.