Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6667939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:59:11+00:00 2026-05-26T02:59:11+00:00

How to move a UIButton and UImageView from one place to another automatically when

  • 0

How to move a UIButton and UImageView from one place to another automatically when i clicking a button. I’m also created a UIButton and UIImageView programmatically within scrollview. But i want when i clicking the button the another UIImage and also a button move to specified place.

Here is my 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;
}

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

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

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:59:11+00:00Added an answer on May 26, 2026 at 2:59 am

    Change the frame in the button click.Do this in – (void)buttonClicked1 method

    bgImage1.frame=CGRectMake(20,30+x,100,100);
    myButton1.frame = CGRectMake(120, 65+x, 70, 30);
    

    or

    - (void)buttonClicked1
    {
    bgImage1.frame=bgImage.frame;
        myButton1.frame = myButton.frame;
    [bgImage removeFromSuperview];
    [bgImage release];
    bgImage=nil;
        myButton.enabled=NO;
    myButton.hidden=YES;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to move a file or folder from one place to another
I've been attempting move a directory structure from one location to another in Subversion,
How to move a sub directory from one directory to another, given that both
I am attempting to move a highly referenced class from one namespace to another.
I'm using : [button addTarget:self action:@selector(moved:) forControlEvents:UIControlEventTouchDragInside]; Function code move: - (IBAction)moved:(id)sender { UIButton
I'm trying to have a button move to a co-ordinates, pause, move to another
I move a UIImageView with touchesBegan , touchesMoved , touchesEnded . It works well,
We just did a move from storing all files locally to storing them on
I need to move data from a datareader into a Farpoint Spreadsheet component in
I am planning to move my vmWare's Virtual Machines from a Windows host to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.