0

除了问题的标题之外,我不知道如何描述问题:我有一个带有标题的按钮,在单击它时会出现,但不是处于正常状态。我四处张望无济于事。

如果您需要查看特定代码或想要其他详细信息(我相信您会这样做),请告诉我。

编辑:按钮是在笔尖中创建的,但这里是设置标题并处理按钮子视图的代码。

[chapterButton setTitle:[NSString stringWithFormat:@"%@: %d",newBookName,newChapter] forState:UIControlStateNormal];

UIImageView *triunghiView = (UIImageView *) [chapterButton viewWithTag:kTagTriangleView];
if(!triunghiView)
{
    triunghiView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"triunghi.png"]] autorelease];
    [triunghiView setContentMode:UIViewContentModeCenter];
    [triunghiView setTag:kTagTriangleView];
    [triunghiView sizeToFit];
    [chapterButton addSubview:triunghiView];

}

[triunghiView setCenter:CGPointMake(chapterButton.titleLabel.frame.origin.x + chapterButton.titleLabel.frame.size.width + triunghiView.frame.size.width + 5, chapterButton.frame.size.height/2)];
4

2 回答 2

3

我最近遇到了这个问题,您还必须设置按钮的标题颜色,否则它会变成白色并看起来不可见(在圆形矩形按钮的默认设置中)。

[btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

但是,这也可能是 Kjuly 的答案!没有代码很难说。

于 2012-05-01T08:41:29.163 回答
0

没有代码,好吧,猜你可能为你的标题设置了错误的状态。

[yourButton setTitle:@"Title" forState:UIControlStateNormal];
于 2012-05-01T08:36:33.990 回答