我的申请中又遇到了另一个问题,我浪费了很多时间。 是否有人可以帮助解决这个问题。
实际上我有一个事件,我应该给那个事件评级,因为我把代码编写为:
在CellForRowAtIndexPath中......我的代码为:
(UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MasterViewIdentifier"];
//UITableViewCell *cell = nil;
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)
{
UIImage *whiteImg = [UIImage imageNamed:@"white_star.png"] ;
UIImage *yellowImg = [UIImage imageNamed:@"yellow_Star.png"] ;
UIButton *button1 = [[UIButton alloc]initWithFrame:CGRectMake(159, 15, 25, 20)];
[button1 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
button1.tag = 1;
UIButton *button2 = [[UIButton alloc]initWithFrame:CGRectMake(185, 15, 25, 20)];
[button2 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
button2.tag = 2;
UIButton *button3 = [[UIButton alloc]initWithFrame:CGRectMake(211, 15, 25, 20)];
[button3 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
button3.tag = 3;
UIButton *button4 = [[UIButton alloc]initWithFrame:CGRectMake(237, 15, 25, 20)];
[button4 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
button4.tag = 4;
UIButton *button5 = [[UIButton alloc]initWithFrame:CGRectMake(263, 15, 25, 20)];
[button5 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
button5.tag = 5;
if(event.eventRatings == 1)
{
[button1 setBackgroundImage:yellowImg forState:UIControlStateNormal];
[button2 setBackgroundImage:whiteImg forState:UIControlStateNormal];
[button3 setBackgroundImage:whiteImg forState:UIControlStateNormal];
[button4 setBackgroundImage:whiteImg forState:UIControlStateNormal];
[button5 setBackgroundImage:whiteImg forState:UIControlStateNormal];
}
else if(event.eventRatings == 2)
{
[button1 setBackgroundImage:yellowImg forState:UIControlStateNormal];
[button2 setBackgroundImage:yellowImg forState:UIControlStateNormal];
[button3 setBackgroundImage:whiteImg forState:UIControlStateNormal];
[button4 setBackgroundImage:whiteImg forState:UIControlStateNormal];
[button5 setBackgroundImage:whiteImg forState:UIControlStateNormal];
}
else if(event.eventRatings == 3)
{
[button1 setBackgroundImage:yellowImg forState:UIControlStateNormal];
[button2 setBackgroundImage:yellowImg forState:UIControlStateNormal];
[button3 setBackgroundImage:yellowImg forState:UIControlStateNormal];
[button4 setBackgroundImage:whiteImg forState:UIControlStateNormal];
[button5 setBackgroundImage:whiteImg forState:UIControlStateNormal];
}
else if(event.eventRatings == 4)
{
[button1 setBackgroundImage:yellowImg forState:UIControlStateNormal];
[button2 setBackgroundImage:yellowImg forState:UIControlStateNormal];
[button3 setBackgroundImage:yellowImg forState:UIControlStateNormal];
[button4 setBackgroundImage:yellowImg forState:UIControlStateNormal];
[button5 setBackgroundImage:whiteImg forState:UIControlStateNormal];
}
else if(event.eventRatings == 5)
{
[button1 setBackgroundImage:yellowImg forState:UIControlStateNormal];
[button2 setBackgroundImage:yellowImg forState:UIControlStateNormal];
[button3 setBackgroundImage:yellowImg forState:UIControlStateNormal];
[button4 setBackgroundImage:yellowImg forState:UIControlStateNormal];
[button5 setBackgroundImage:yellowImg forState:UIControlStateNormal];
}
else
{
[button1 setBackgroundImage:whiteImg forState:UIControlStateNormal];
[button2 setBackgroundImage:whiteImg forState:UIControlStateNormal];
[button3 setBackgroundImage:whiteImg forState:UIControlStateNormal];
[button4 setBackgroundImage:whiteImg forState:UIControlStateNormal];
[button5 setBackgroundImage:whiteImg forState:UIControlStateNormal];
}
[elementView addSubview:button1];
[button1 release];
[elementView addSubview:button2];
[button2 release];
[elementView addSubview:button3];
[button3 release];
[elementView addSubview:button4];
[button4 release];
[elementView addSubview:button5];
[button5 release];
if(isRightButton == YES)
{
button1.enabled = NO;
button2.enabled = NO;
button3.enabled = NO;
button4.enabled = NO;
button5.enabled = NO;
}
else if(isRightButton == NO)
{
button1.enabled = YES;
button2.enabled = YES;
button3.enabled = YES;
button4.enabled = YES;
button5.enabled = YES;
}
[elementView addSubview:ratingsTitleLabel];
cell.accessoryType = UITableViewCellAccessoryNone;
}
return cell;
}
And the action of the button is written as:
-(void)buttonAction:(id)sender
{
rating = [sender tag];
printf("\n Ratig Value inside Button Action~~~~~~~~~~~~~~~~%d",rating);
event.eventRatings = rating;
[tableView reloadData];
}
当我在3.1.2 O.S的simlator中构建应用程序时,通过显示星形图像可以正常工作。 我的问题是当我在3.1.2 O.S设备中构建时,图像没有显示。我检查了文件名中的casesensitivity的代码及其gud但是我没有看到要显示的图像。
伙计们帮助我解决这个问题。
谢谢你, Monish Kumar。
答案 0 :(得分:0)
试试这个: - 从iPhone删除您的应用程序 - 从构建菜单中清除所有tagets - 将图像复制到另一个目录中 - 从项目中删除图像(删除时单击“还移至废纸篓”) - 再次添加图像 - 建立并去
希望它有效。