Моя проблема в том, что у меня есть пользовательская кнопка и ImageView, к которой я добавил Image.I сделал этот imageView к пользовательской кнопке как подпредставление. Когда я запускаю его в симуляторе, он работает нормально, но когда я запускаю его в Device не отображалось изображение в кнопке.
Я написал код как:
In cellForRowtIndexPath
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MasterViewIdentifier"];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"MasterViewIdentifier"] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UIView* elementView = [[UIView alloc] initWithFrame:CGRectMake(20,170,320,280)];
elementView.tag = 0;
elementView.backgroundColor=[UIColor clearColor];
[cell.contentView addSubview:elementView];
[elementView release];
}
UIView* elementView = [cell.contentView viewWithTag:0];
elementView.backgroundColor=[UIColor clearColor];
for(UIView* subView in elementView.subviews)
{
[subView removeFromSuperview];
}
if(indexPath.section == 8)
{
imageView.image = [UIImage imageNamed:@"yellow_Star.png"];
MyCustomButton *button1 = [[MyCustomButton alloc]initWithRating:1];
[button1 setFrame:CGRectMake(159, 15, 25, 20)];
[button1 setShowsTouchWhenHighlighted:YES];
[button1 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
[button1 addSubview:imageView];
[elementView addSubview:button1];
[button1 release];
[imageView release];
}
return cell;
}
и в моей кнопкеДействие:
-(void)buttonAction:(MyCustomButton*)sender
{
rating = [sender ratingValue];
event.eventRatings = rating;
[tableView reloadData];
}
и класс MyCustomButton:
у меня есть метод как
-(MyCustomButton*) initWithRating:(NSInteger)aRatingValue
{
if (self = [super init])
{
self.ratingValue = aRatingValue;
}
return self;
}
Пожалуйста, помогите ребятам с проблемой dis.
Спасибо,
Мониш.