Ios5 UITableViewCell子类中的IFTweetLabel未显示

Ios5 UITableViewCell子类中的IFTweetLabel未显示,ios5,uitableview,ios,Ios5,Uitableview,Ios,现在我正在制作一个twitter应用程序,我正在使用IFTweetLabel。我创建了一个TableViewCell子类,但当我运行它时,标签dosent出现了 以下是.h: #import <UIKit/UIKit.h> #import "IFTweetLabel.h" @interface twitterTextCell : UITableViewCell @property (strong, nonatomic) IFTweetLabel *customtextLabel;

现在我正在制作一个twitter应用程序,我正在使用IFTweetLabel。我创建了一个TableViewCell子类,但当我运行它时,标签dosent出现了

以下是.h:

#import <UIKit/UIKit.h>
#import "IFTweetLabel.h"

@interface twitterTextCell : UITableViewCell
@property (strong, nonatomic) IFTweetLabel *customtextLabel;

@end
以下是tableviewdelegate中cellforrow中的代码:

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

twitterTextCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {

    cell = [[twitterTextCell alloc] initWithStyle:UITableViewCellStyleSubtitle  reuseIdentifier:CellIdentifier];
        }

NSDictionary *tweet = [self.timeLineData objectAtIndex:indexPath.row];

    if ([tweet objectForKey:@"text"] != nil) {

        NSString *allText = [[tweet objectForKey:@"text"] stringByDecodingHTMLEntities];

        cell.customtextLabel.numberOfLines = 4;
        cell.textLabel.numberOfLines = 4;
        cell.customtextLabel.text = allText;
        cell.textLabel.text = allText;
        cell.customtextLabel.linksEnabled = YES;


        NSDictionary *whoPostedTweet = [tweet objectForKey:@"user"];
        cell.detailTextLabel.text = [whoPostedTweet objectForKey:@"name"];
        NSURL *imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [whoPostedTweet objectForKey:@"profile_image_url"]]];
        [cell.imageView setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
        cell.backgroundColor = [UIColor clearColor];
        [cell.imageView.layer setCornerRadius:7.0f];
        [cell.imageView.layer setMasksToBounds:YES];
        return cell;

        } else {

        [self getTwitterData];
        NSLog(@"nil called(else) ");
        return cell;
        }


    return cell;
        }

所有这些之后,只显示图像和detailtextview。我删除了默认的文本视图,因为如果我没有,文本会正常显示,但它不是IFTweetLabel。我还有一个问题,那就是如何重新定位detailtextabel,使其位于IFTweetLabel之下。非常感谢您所做的一切,在这两个问题上我都需要帮助。

我认为您的问题在于您没有分配customTextLabel

initWithStyle
中设置背景色之前,只需分配相同的颜色即可。
例如,
self.customtextLabel=[[IFTweetLabel alloc]init]autorelease]

我认为您的问题在于您没有分配customTextLabel

initWithStyle
中设置背景色之前,只需分配相同的颜色即可。 例如,
self.customtextLabel=[[IFTweetLabel alloc]init]autorelease]

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

twitterTextCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {

    cell = [[twitterTextCell alloc] initWithStyle:UITableViewCellStyleSubtitle  reuseIdentifier:CellIdentifier];
        }

NSDictionary *tweet = [self.timeLineData objectAtIndex:indexPath.row];

    if ([tweet objectForKey:@"text"] != nil) {

        NSString *allText = [[tweet objectForKey:@"text"] stringByDecodingHTMLEntities];

        cell.customtextLabel.numberOfLines = 4;
        cell.textLabel.numberOfLines = 4;
        cell.customtextLabel.text = allText;
        cell.textLabel.text = allText;
        cell.customtextLabel.linksEnabled = YES;


        NSDictionary *whoPostedTweet = [tweet objectForKey:@"user"];
        cell.detailTextLabel.text = [whoPostedTweet objectForKey:@"name"];
        NSURL *imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [whoPostedTweet objectForKey:@"profile_image_url"]]];
        [cell.imageView setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
        cell.backgroundColor = [UIColor clearColor];
        [cell.imageView.layer setCornerRadius:7.0f];
        [cell.imageView.layer setMasksToBounds:YES];
        return cell;

        } else {

        [self getTwitterData];
        NSLog(@"nil called(else) ");
        return cell;
        }


    return cell;
        }