【发布时间】:2010-07-10 06:30:38
【问题描述】:
我在下面的代码中得到分配计数加一。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"MasterViewIdentifier"] autorelease];
cell.accessoryType = UITableViewCellAccessoryNone;
cell.selectionStyle = UITableViewCellEditingStyleNone;
UIView* elementView = [ [UIView alloc] initWithFrame:CGRectMake(5,5,312,480)];
elementView.tag = 0;
[cell.contentView addSubview:elementView];
[elementView release];
}
UIView* elementView = [cell.contentView viewWithTag:0];
for(UIView* subView in elementView.subviews)
{
[subView removeFromSuperview];
}
if(indexPath.section==0)
{
if(indexPath.row==0)
{
// i have tried like this but getting exception.
/*
UIImage *cellBackImag=[UIImage imageNamed:@"celltop.png" ];
UIImageView* imaeView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 300, 43)];
imaeView.image=cellBackImag;
[elementView addSubview:imaeView];
[imaeView release];
[cellBackImag release];
*/
// here I am getting uiimage count allocation count
UIImageView* imaeView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"celltop.png" ]];
imaeView.frame=CGRectMake(0, 0, 300, 43);
[elementView addSubview:imaeView];
[imaeView release];
请帮我解决这个问题,谢谢, 马丹·莫汉
【问题讨论】:
标签: objective-c count uiimage memory-management