2013-02-23 3 views
1

내 탐색 도구 모음에서 Edit 단추를 사용하여 테이블보기를 편집 모드로 설정합니다. 막대 단추의 레이블 기본값은 Edit입니다.UITableView : 이름 바꾸기 편집 단추 (UIBarButtonSystemItemEdit)

어떻게 라벨을 다른 것으로 변경할 수 있습니까?

테이블을 편집 모드로 설정해야하므로 내장 된 Edit 버튼에 의해 트리거되는 setEditing:animated: 동작을 얻으려고하므로 다른 BarButton 유형을 사용할 수 없습니다.

self.editToolbarButton = [[UIBarButtonItem alloc] 
    initWithBarButtonSystemItem:UIBarButtonSystemItemEdit 
    target:self action:@selector(setSearchEditMode:)]; 

답변

2

두 개의 라벨로 나만의 버튼을 만들면됩니다.

UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithTitle:@"Title1" style: UIBarButtonItemStyleBordered target:self action:@selector(setSearchEditMode:)]; 
btn.possibleTitles = [NSSet setWithObjects:@"Title1", @"Title2", nil]; 
self.editToolbarButton = btn; 

- (void)setSearchEditMode:(UIBarButtonItem *)button { 
    // Toggle the view controller's editing state 
    [self setEditing:!self.editing animated:YES]; 

    // Update the button's title 
    button.title = self.editing ? @"Title2" : @"Title1"; 

    // other processing 
}