UFTableViewCell子类中的IFTweetLabel未显示

时间:2012-07-05 18:29:19

标签: ios5 uitableview ios

现在我正在制作推特应用程序而我正在使用IFTweetLabel。我制作了一个TableViewCell子类,但是当我运行它时,标签剂量显示出来。

这是.h:

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

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

@end

以下是实施:

#import "twitterTextCell.h"

@implementation twitterTextCell
@synthesize customtextLabel;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
    // Initialization code
    customtextLabel.backgroundColor = [UIColor orangeColor];
    self.customtextLabel.frame = CGRectMake(240, 60, 345, 109);
    [self addSubview:customtextLabel];

    NSLog(@"Custom Label Text: %@", customtextLabel.text);
}
return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];

// Configure the view for the selected state
}
-(UILabel *)textLabel
{
return nil;
}

以下是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。我删除了默认的textview,因为如果我没有正常显示文本,但它不是IFTweetLabel。我有一个问题的另一件事是我如何重新定位detailtextabel,以便它在IFTweetLabel下。非常感谢,我需要帮助解决这两个问题。

1 个答案:

答案 0 :(得分:1)

我认为你的问题是你没有分配customTextLabel。

initWithStyle中设置背景颜色之前,请先分配相同内容。 即,self.customtextLabel = [[[IFTweetLabel alloc] init] autorelease];

相关问题