1
現在我正在製作一個Twitter應用程序,並且正在使用IFTweetLabel。我做了一個TableViewCell子類,但是當我運行它時,標籤dosent顯示出來。UITableViewCell子類中的IFTweetLabel未顯示
這裏是.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;
}
這裏是在cellforrow在tableviewdelegate代碼:
- (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下。任何事情都非常感激,我需要幫助解決這兩個問題。
謝謝Soooooo很多!!!!!! – virindh 2012-07-05 19:57:43