开发者

iphone how to disable scrolling of tableview cells

开发者 https://www.devze.com 2023-03-22 14:46 出处:网络
i have 4 rows in my table view as ahome screen. First I want to disable scrolling o开发者_Go百科f cells up and down. Secondly, I want to put a logo image to the 4th cell.

i have 4 rows in my table view as a home screen. First I want to disable scrolling o开发者_Go百科f cells up and down. Secondly, I want to put a logo image to the 4th cell.

Can anyone suggest me right way to do so?

Thanks in advance.


to disable scrolling use

tableView.scrollEnabled = NO;

and in cellForRowAtIndexPath method

use this code snippet after cell has been created

if(indexPath.row == 3) {
  cell.imageView.image = [UIImage imageNamed:@"nameOfImage.png"];
}


self.tableView.scrollEnabled = NO

For adding image to your cells, go to the cellForRowAtIndexPath and create UIImage and add them them as subviews to your cells.

 if (indexPath.row ==3)
    // allocate your image 1
   [cell.contentView addSubview: image1];

 // and so on. 

Edit :

Just try this.

UIImageView *sampleImage = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sample.jpg"]] autorelease];
sample.frame = CGRectMake(20, 10, 75, 75);
[cell addSubview:sampleImage];
0

精彩评论

暂无评论...
验证码 换一张
取 消