2013-10-25 2 views
0

내 tableViewCell에서 선택 윤곽 텍스트를 만들고 싶습니다. 그래서 나는 몇 가지 코드 발견tableview에서 선택 윤곽 텍스트를 만드는 방법

- (void)fireTimer 
{ 
    NSMutableString *mutableText = [NSMutableString stringWithString: textLabel.text]; 
    //Takes the first character and saves it into a string 
    NSString *firstCharText = [mutableText substringWithRange: NSMakeRange(0, 1)]; 
    //Removes the first character 
    [mutableText deleteCharactersInRange: NSMakeRange(0, 1)]; 
    //Adds the first character string to the initial string 
    [mutableText appendString: firstCharText]; 

    textLabel.text = mutableText; 
} 

을하지만 난 오류가 내 프로젝트에이 코드를 붙여 넣을 때, textLabel라는 찾을 수 없습니다. 하지만 TextLabel은 Cell의 텍스트입니다. 그래서이 코드에서 tableViewCell의 TextLabel을 찾으려면 어떻게해야합니까? tableViewCell 텍스트 또는 세부 텍스트에서 선택 윤곽 코드를 알 수 있습니다. 감사합니다

+0

이 링크, http://blog.stormyprods.com/2009/10/simple-scrolling-uilabel-for-iphone.html를 참조하십시오. 그것이 효과가 있기를 바랍니다. – karthika

+0

UILabel에 대한 스크롤이 없습니다. 하지만 난 세포 에서이 표준 텍스트 스크롤 싶어요 – Genevios

+0

당신은 사용자 정의 셀 있습니까? 또는이 cell.textLabel처럼 사용 하시겠습니까? – karthika

답변

2

당신은 당신의 프로젝트

가져 오기 사용자 정의 셀 클래스에서이 클래스에서 이러한 파일을 추가하려면이 링크를 다음 http://stormyprods.com/sampleCode/AutoScrollLabel.zip

에서 AutoScrollLabel 파일을 다운로드 할 수 있습니다, #import "AutoScrollLabel.h"

@interface YourCustomCell : UITableViewCell 

@property(nonatomic,strong)IBOutlet AutoScrollLabel *textLabel; 
@property(nonatomic,strong)IBOutlet AutoScrollLabel *detailLabel; 

@end 

와 연결 그 라벨 콘센트는 YourCustomCell.xib 파일에 있습니다. 당신의 ViewController cellForRowIndexPath 방법에

,

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *cellIdentifier = @"Cell"; 

    YourCustomCell *cell= (answerCustomCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 
    if(cell == nil) 
    { 

     NSArray *topLevelObjects = [[NSBundle mainBundle]loadNibNamed:@"YourCustomCell" owner:self options:nil]; 

     for(id currrentObject in topLevelObjects) 
     { 
      if([currrentObject isKindOfClass:[UITableViewCell class]]) 
      { 
       cell = (YourCustomCell*)currrentObject; 
       break; 
      } 
     } 
    } 

cell.textLabel.text = @"Your text"; 
cell.detailLabel.text = @"Your text"; 

return cell; 

}