我想在iPhone中使用下面的布局类型(使用UItableView,Uitableviewcell,Uilabel和Uiimageview)。ios - 在Uitableviewcell中的Uilabel和UIimageview
(假设浅蓝色点==的UIImageView)
在每种的UITableViewCell我有1周的UIImageView和1的UILabel。 两个控件的起始照明都是相同的左前。 我的uilabel的内容是动态的,图片只是一张静态图片。
与uilabel的内容相比,图像是非常小的。因此,我的图像中心垂直和水平。但我只想在左上角。
编辑:
我已经在Uitableviewcell
为此但是,如果具有的UILabel线的数目为2个或更多的则imageview的立场发生变化。 它垂直和水平中心。但我想只在左上角位置的ImageView线1,2,3的UILabel的数量.... n是否
我的代码是在这里:
In CommonCustomeCell.m
- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier];
if (self) {
dotImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"dotPoint.png"]];
dotImage.opaque = YES;
[self.contentView addSubview:dotImage];
titleName3 = [[UILabel alloc] init];
titleName3.textAlignment = UITextAlignmentLeft;
titleName3.backgroundColor = [UIColor clearColor];
titleName3.adjustsFontSizeToFitWidth = FALSE;
titleName3.font = [UIFont systemFontOfSize:14];
titleName3.textColor = [UIColor colorWithRed:17.0/255.0 green:72.0/255.0 blue:147.0/255.0 alpha:1];
titleName3.lineBreakMode = NSLineBreakByWordWrapping;
[titleName3 sizeToFit];
[self.contentView addSubview:titleName3];
}
-(void)layoutSubviews
{
frame = CGRectMake(20,2,self.bounds.size.width - 45 , self.bounds.size.height);
[titleName3 setFrame:frame];
frame = CGRectMake(4,10,dotImage.frame.size.width,dotImage.frame.size.height);
self.dotImage.frame = frame;
}
}
在RootViewController.m文件
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CommonCustomeCell *cell = (CommonCustomeCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[CommonCustomeCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
[cell.dotImage5 setImage:[UIImage imageNamed:@"myLogo.png"]];
cell.titleName3.text = [[myArr objectAtIndex:indexPath.row] objectForKey:@"title"];
}
}
帮助我,在此先感谢。
创建自定义“的UITableViewCell”,和地方的ImageView任何你想要的。 – jamapag 2013-02-19 09:04:24
检查我编辑的问题。 – 2013-02-19 09:36:58
你能否在你的自定义单元格中显示创建imageView的代码? – jamapag 2013-02-19 14:23:41