2013-07-29 2 views
0

편집 단추를 클릭 할 때 색을 변경하려는 텍스트 필드 (countTotalFieldUniversal)에 자리 표시 자 텍스트가 있습니다. "... 색상은 회색한다" "플래그 '예'하고 있음을"편집 단추"에서 텍스트 회색 켜기

- (void)setEditing:(BOOL)flag animated:(BOOL)animated 
{ 
    NSLog(@"setEditing called"); 
    [super setEditing:flag animated:animated]; 
    if (flag == YES){ 
    NSLog(@"Flag is yes"); 
    [countTotalFieldUniversal setValue:[UIColor darkGrayColor] 
          forKeyPath:@"_placeholderLabel.textColor"]; 
    NSLog(@"Color should be grey..."); 
} 
else { 
    // Edit not selected 
    } 
} 

내 콘솔 인쇄 아웃하지만 텍스트가 변경되지 않습니다

현재, 내 코드입니다. 텍스트를 잘못 설정합니까?

+0

'[self.countTotalFieldUniversal setNeedsDisplay]'키/값 변경을 받기 위해 필드를 다시 그려야 할 수도 있습니다. –

+0

NSLog (@ "Color는 회색이어야합니다 ... ...") 바로 앞에 추가되었지만 변경되지 않았습니다. 그러나 [countTotalFieldUniversal setNeedsDisplay]를 수행해야했습니다. 그것은 self.countTotalFieldUniversal을 수락하지 않을 것입니다 ... – AllieCat

+0

나는 테이블 뷰를 "새로 고침"해야한다는 것에 동의합니다. 난 그냥 어떻게 확신하지 ... – AllieCat

답변

0

레이크가 대부분 맞았습니다. 데이터를 다시로드해야했습니다.

내가 내 setEditing 기능에 부울 (editClicked)를 추가하여 텍스트 색상을 변경 : 내 테이블의 cellForRowAtIndexPath 함수에서

- (void)setEditing:(BOOL)flag animated:(BOOL)animated 
{ 
    NSLog(@"setEditing called"); 
    [super setEditing:flag animated:animated]; 
    if (flag == YES){ 
    editClicked = true; 
    [tableView reloadData]; 
} 
else { 
    editClicked = false; 
    } 
} 

, 나는 다음을 추가 if 문 :

//If editClicked is true, change text to grey 
       if (editClicked == true){ 
        [countTotalFieldUniversal setValue:[UIColor darkGrayColor] 
              forKeyPath:@"_placeholderLabel.textColor"]; 
       } 
       else { 
        // Save the changes if needed and change the views to noneditable. 
        [countTotalFieldUniversal setValue:[UIColor blackColor] 
              forKeyPath:@"_placeholderLabel.textColor"]; 
       } 

감사합니다 도움을 얻으려면 모두 (es Lakesh and Kyle)!