How to move a UIButton and UIImageView from One place to Another in iphone?
<p>How to move a <code>UIButton</code> and <code>UImageView</code> from one place to another automatically when i clicking a button. I'm also created a <code>UIButton</code> and <code>UIImageView</code> programmatically within scrollview. But i want when i clicking the button the another <code>UIImage</code> and also a button move to specified place.</p>

<p>Here is my code</p>

<pre><code>if (i==0)
{
    bgImage = [[UIImageView alloc] initWithFrame:CGRectMake(20,30+x,100,100)];
    bgImage.image = [UIImage imageNamed:@"iphone.png"];
    [self.view addSubview:bgImage];
    [scrollview addSubview:bgImage];

    myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    myButton.frame = CGRectMake(120, 65+x, 70, 30); // position in the parent view and set the size of the button
    [myButton setTitle:@"Delete" forState:UIControlStateNormal];
    [myButton addTarget:self action:@selector(buttonClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:myButton];
    [scrollview addSubview:myButton];
    x=x+100;
}
if (i==1) 
{
    bgImage1 = [[UIImageView alloc] initWithFrame:CGRectMake(20,30+x,100,100)];
    bgImage1.image = [UIImage imageNamed:@"iphone.png"];
    [self.view addSubview:bgImage1];
    [scrollview addSubview:bgImage1];

    UIButton *myButton1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    myButton1.frame = CGRectMake(120, 65+x, 70, 30); // position in the parent view and set the size of the button
    [myButton1 setTitle:@"Delete" forState:UIControlStateNormal];
    [myButton1 addTarget:self action:@selector(buttonClicked1) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:myButton1];
    [scrollview addSubview:myButton1];
    x=x+100;
}

- (void)buttonClicked1
{
    [bgImage removeFromSuperview];
    [bgImage release];
    bgImage=nil;
    myButton.enabled=NO;
    myButton.hidden=YES;
}
</code></pre>

<p>When i clicking <code>buttonclicked1</code> button the <code>bgImage</code> and <code>myButton</code> is removed its place and i want <code>bgImage1</code> and <code>myButton1</code> is moved to these place without any modification.</p>

<p>How to do this. Anybody give me the code pls. I cant move it. How to do this. Pls help me. </p>

<p>Thanks in advance.</p>
