I am using following code:
slidingImageIconView=[[UIScrollView alloc]init];
[slidingImageIconScrollView setContentSize:CGSizeMake(110, 90)];
UIButton *iconImageSlide=[[UIButton alloc] init];
[iconImageSlide setImage:[UIImage imageNamed:@"dummy_img.jpg"] forState:UIControlStateNormal];
[slidingImageIconScrollView addSubview:iconImageSlide];
but my button is not adding in scroll view, i know i am missing something very silly but please help me..
I notice that you have
slidingImageIconViewandslidingImageIconScrollView. Is that a typo? I’ve left it like that in my examples here.You need to
initWithFramein order to set the button position and size:If you want to make the button the same size as the image – then the following rearrangement would allow that. Also note that I’ve used setBackgroundImage instead of setImage. I tend to use setImage to put an ‘icon’ on the button, but setBackgroundImage for the actual button-image.