小编luc*_*cas的帖子

uitableviewcell textlabel太长,推出detailtextlabel看不见

当我使用UITableViewCellStyleValue1时,我得到了一个长字符串的textLabel,并且不知何故,detailTextLabel从视图中被推出.

当我缩短textLabel文本时,我可以看到detailTextLabel的文本.

反正是否有限制textLabel的宽度在上面的样式,以便它将截断textLabel与它太长?

我的代码是:

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

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];

}

cell.textLabel.lineBreakMode = UILineBreakModeTailTruncation;

//---get the letter in each section; e.g., A, B, C, etc.---
NSString *alphabet = [self.currencyNameIndex objectAtIndex:[indexPath section]];

//---get all states beginning with the letter---
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF beginswith[c] %@", alphabet];
self.currencyList = [self.keyCurrencyName filteredArrayUsingPredicate:predicate];

if ([self.currencyList count] > 0) 
{
    NSString …
Run Code Online (Sandbox Code Playgroud)

iphone uitableview textlabel

28
推荐指数
3
解决办法
2万
查看次数

将CALayer绘制成CGContext

我有以下代码:

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSaveGState(context);

CALayer *sublayer = [CALayer layer];
sublayer.backgroundColor = [UIColor orangeColor].CGColor;
sublayer.cornerRadius = 20.0;
sublayer.frame = CGRectMake(20, 0, 300, 20);

[sublayer setNeedsDisplay];
[sublayer drawInContext:context];

UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return newImage;
Run Code Online (Sandbox Code Playgroud)

但是当我查看返回的newImage时,只有一个空图像.当我将drawInContext更改为renderInContext时,我得到了上面的子图层,但似乎坐标系统搞得一团糟.

知道为什么上面的drawInContext不起作用?

calayer cgcontext

7
推荐指数
2
解决办法
6773
查看次数

标签 统计

calayer ×1

cgcontext ×1

iphone ×1

textlabel ×1

uitableview ×1