2013-10-25 2 views
0

Я хочу сделать текст marquee в моем столеViewCell. Так я нашел код:Как сделать текст marquee в 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 свой текст в ячейке. Итак, что я делаю для поиска TextLabel из tableViewCell в этом коде. Возможно, вы знаете какой-либо код для выделения в текстовом или текстовом тексте tableViewCell. Благодаря

+0

видеть эту ссылку, http://blog.stormyprods.com/2009/10/simple-scrolling-uilabel-for-iphone.html. надеюсь, что это работает. – karthika

+0

Нет прокрутки для UILabel. Но я хочу прокрутить этот стандартный текст в ячейке – Genevios

+0

Вы настраиваете ячейку? или использовать как this cell.textLabel? – karthika

ответ

2

Вы можете загрузить файлы AutoScrollLabel по этой ссылке http://stormyprods.com/sampleCode/AutoScrollLabel.zip

Затем добавьте эти файлы в свой проект

Импорта этого класс в пользовательском классе клеток, #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; 

}