Я пытаюсь поместить UIButton
внутрь UITableViewCell
.
В UITableView
также есть ячейки, содержащие UILabels
, а в ячейках есть градиентный фон. Проблема, которую я вижу, заключается в том, что моя UIButton
- это просто черная ячейка с заливкой без отображения текста, и изменение свойств цвета и цвета фона, похоже, ничего не делает.
Вот код, который я использую для создания кнопки:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"InAppViewController, doing this - width= %f", self.wdth);
static NSString *ProductTableIdentifier = @"ProductTableIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ProductTableIdentifier];
if (cell == nil)
{
if (self.wdth >= 700) {
CGRect cellFrame = CGRectMake(0, 0, (self.wdth - 100), 40);
cell = [[[UITableViewCell alloc] initWithFrame:cellFrame reuseIdentifier: ProductTableIdentifier] autorelease];
// Set up some labels...
CGRect seenValueRect = CGRectMake(self.wdth-320, 0, 100, 40);
UIButton *seenValue = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[seenValue setBackgroundColor:[UIColor greenColor]];
seenValue.tag = kSeenValueTag;
seenValue.frame = seenValueRect;
[seenValue setTitle:@"I'm a clone" forState:UIControlStateNormal];
[cell.contentView addSubview:seenValue];
[seenValue release];
// Continue setting up cell...
Ссылка на вставку содержит код для всей функции cellForRowAtIndexPath()
(для рассматриваемого UITableView
).
http://pastebin.com/bpEyfruE