2013-04-03 138 views
2

我用这个https://github.com/SebastienThiebaud/STTweetLabelSTTweetLabel介绍的UITableViewCell

但我想将它添加到的UITableViewCell如下

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

static NSString *CellIdentifier = @"Cell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

if (!cell) { 

cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
cell.selectionStyle = UITableViewCellSelectionStyleNone; 

} 

STTweetLabel *_tweetLabel = [[STTweetLabel alloc] initWithFrame:CGRectMake(20.0, 60.0, 280.0, 230.0)]; 
[_tweetLabel setFont:[UIFont fontWithName:@"HelveticaNeue" size:17.0]]; 
[_tweetLabel setTextColor:[UIColor blackColor]]; 
STLinkCallbackBlock callbackBlock = ^(STLinkActionType actionType, NSString *link) { 

    SString *displayString = NULL; 

    switch (actionType) { 

     case STLinkActionTypeAccount: 
      displayString = [NSString stringWithFormat:@"Twitter account:\n%@", link]; 
      break; 

     case STLinkActionTypeHashtag: 
      displayString = [NSString stringWithFormat:@"Twitter hashtag:\n%@", link]; 
      break; 

     case STLinkActionTypeWebsite: 
      displayString = [NSString stringWithFormat:@"Website:\n%@", link]; 
      break; 
    } 

    NSLog(@"%@",displayString); 

    }; 

    [_tweetLabel setCallbackBlock:callbackBlock]; 
    [_tweetLabel setText:@"http://www.google.com"]; 
    [cell addSubview:_tweetLabel]; 

    return cell; 

} 

但错误是:

-[__NSArrayM set]: unrecognized selector sent to instance 0x750b160 
2013-04-03 15:36:36.425 Shahona Fashion[18426:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM set]: unrecognized selector sent to instance 0x750b160' 

所以我的问题是,是否有可能添加intro tableView单元格,或者有什么方法可以通过这种方式来检测url?

在此先感谢..

回答

0

如果我理解你的问题,你希望你的表格的第一个单元是与众不同?

你可以尝试一个简单的if语句。

if (indexPath.row == 0) 
{ 
    //set up as "intro cell" 
} else { 
    //set up the rest of your cells 
} 

此外,它看起来不像你的错误是与你的表上的代码有关。看看你的应用中的任何阵列。

+0

不,这不是我的问题,我只是问关于使用STLweetLabel进入细胞 – SimpleojbC

+0

道歉。我误解了这个问题。您最好创建一个自定义单元类并在那里实现您的STTweetLabel。但在你做任何事情之前,你必须摆脱你的错误,正如我所说的,它与某个数组有关。 – joeByDesign

0

您的问题与STTweetLabel有关。这是一个在STTweetLabel 3.0中修复的bug。