0
     - (void)viewDidLoad
{
    NSLog(@"Welcome to Home Page");
    [super viewDidLoad];

   self.view.backgroundColor=[[UIColor alloc]initWithPatternImage:[UIImage imageNamed:@"bg-image.png"]];


// Do any additional setup after loading the view, typically from a nib.
}



- (void)loadView {


    CGRect fullScreenRect=[[UIScreen mainScreen] applicationFrame];
    scrollView=[[UIScrollView alloc] initWithFrame:fullScreenRect];
    scrollView.contentSize=CGSizeMake(1400, 100);

    UIImageView *tempImageView2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sti01.png"]];
    tempImageView2.frame=CGRectMake(10, 60, 200, 200);
    [scrollView addSubview:tempImageView2];


    UIImageView *tempImageView3 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sti02.png"]];
    tempImageView3.frame=CGRectMake(240, 60, 200, 200);
    [scrollView addSubview:tempImageView3];

    UIImageView *tempImageView4 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sti03.png"]];
    tempImageView4.frame=CGRectMake(470, 60, 200, 200);
    [scrollView addSubview:tempImageView4];

    UIImageView *tempImageView5 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sti04.png"]];
    tempImageView5.frame=CGRectMake(700, 60, 200, 200);
    [scrollView addSubview:tempImageView5];


    UIImageView *tempImageView6 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sti05.png"]];
    tempImageView6.frame=CGRectMake(930, 60, 200, 200);
    [scrollView addSubview:tempImageView6];

    UIImageView *tempImageView7 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sti06.png"]];
    tempImageView7.frame=CGRectMake(1160, 60, 200, 200);
    [scrollView addSubview:tempImageView7];



    self.view=scrollView;
    [scrollView addSubview:tempImageView2];
    [scrollView addSubview:tempImageView3];
    [scrollView addSubview:tempImageView4];
    [scrollView addSubview:tempImageView5];
    [scrollView addSubview:tempImageView6];
    [scrollView addSubview:tempImageView7];

    scrollView.userInteractionEnabled = YES;
    btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(22, 100, 1800, 500);
   // [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(buttonTest:) forControlEvents:UIControlEventTouchUpInside];    
    [scrollView addSubview:btn];


}


- (IBAction)buttonTest:(id)sender {
    MSDescriptionpage *aSecondPageController = [[MSDescriptionpage  alloc] initWithNibName:@"MSDescriptionpage" bundle:nil];        
    [self.navigationController pushViewController:aSecondPageController animated:YES];        
    [aSecondPageController release];

}

How can i set back ground image fixed when i scroll THE CONTENT USING OF UISCROLLVIEW.How to set background image fixed while using Horizontal scrollview in ios.i using many formats but not issue was fixed..

2
  • Please refer this question for your problem. As this is exact duplicate question Commented Jul 28, 2012 at 11:11
  • yes,But in this issue was not fixed...Can u tell the solutions for that.. Commented Jul 28, 2012 at 11:14

1 Answer 1

0

EDIT

enter image description here

Now add the IBOutlate for the scrollView like this .h file

@property (strong, nonatomic) IBOutlet UIScrollView *scrollView;

and in .m file

@synthesize scrollView;

and in xib Control-Drag from file's Owner to the scrollView to assign the IBOutlate to it

this will looks like this

enter image description here

Now

Sign up to request clarification or add additional context in comments.

22 Comments

i did not use uiscrollview in xib...just in programatically...Then where i want to use clear colour..Can u tell briefly
ok then after the alloc init the scrollview use it name and set the background color to [UIColor clearColor] just like this [scrollDisplay setBackgroundColor:[UIColor clearColor]]; here the scrollDisplay is UIScrollView
CGRect fullScreenRect=[[UIScreen mainScreen] applicationFrame]; scrollView=[[UIScrollView alloc] initWithFrame:fullScreenRect];[UIColor clearColor] scrollView.contentSize=CGSizeMake(1400, 100); i use this but not get output.so background also moved.
[scrollView setBackgroundColor:[UIColor clearColor]]; will make your scrollview's background as clearColor or say transparant. Put this line after contentSize line
CGRect fullScreenRect=[[UIScreen mainScreen] applicationFrame]; scrollView=[[UIScrollView alloc] initWithFrame:fullScreenRect];[scrollView setBackgroundColor:[UIColor clearColor]]; scrollView.contentSize=CGSizeMake(1400, 100); Now i use like this same error.I dono why its happen like that.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.