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 9259543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:40:59+00:00 2026-06-18T12:40:59+00:00

I am not a very good programmer so if this is a stupid question

  • 0

I am not a very good programmer so if this is a stupid question forgive me !
I am just learning image transformation in ios
i want to translate a image from one position to another on button click event
Here is the code…

- (IBAction)showinfobybutton:(id)sender {
    CGFloat v1 = imageview.center.x;
    CGFloat v2 = imageview.center.y;
    CGAffineTransform trans = CGAffineTransformTranslate(imageview.transform, v1, v2);
    imageview.transform = trans; 
}

What’s wrong with the code. it only translate in y direction not in x. no matter how much you put the value for v1 function don’t care. any idea what’s going on …..
I am totally stucked
Thank You for any help

  • 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-06-18T12:41:00+00:00Added an answer on June 18, 2026 at 12:41 pm

    In terms of your question about CGAffineTransform, a couple of thoughts:

    1. Are you doing this in init method or viewDidLoad? If so, that may be too early in the view creation process as many of the UIView related properties of the imageview (such as center) are not reliable at that point. Take a look and make sure you’re getting non-zero values for v1 and v2. If you want to look at frame coordinates or the like, you might want to defer that until viewDidAppear or later.

    2. Are you using autolayout? Open up the storyboard or NIB and look at the document properties (below). If you’re moving things around on the screen, you might want to turn that off.

      enter image description here

    3. As an aside, your setting v1 and v2 based upon the center of the imageview is curious. You’re moving the center by the amount of the center. Usually you’d see something like the following:

      CGFloat dx = 100.0;
      CGFloat dy = 200.0;
      
      [UIView animateWithDuration:1.0
                       animations:^{
                           CGAffineTransform trans = CGAffineTransformTranslate(self.someView.transform, dx, dy);
                           imageview.transform = trans;
                       }];
      

      By the way, I animate (a) because that’s often a better user experience; and (b) when doing diagnostics like this, it makes it easier for me to see what it’s changing from and what it’s changing to. If you don’t want animation, obviously don’t use animateWithDuration code.


    By the way, if you want to move a UIView control, if you’re not using autolayout, the most common way is to use animationWithDuration to change either the center or the frame, e.g.:

    [UIView animateWithDuration:1.0
                     animations:^{
                         imageview.center = CGPointMake(newX, newY); // set newX and newY to whatever you want
                     }];
    

    If you’re using autolayout, the process is a little more complicated. One technique in autolayout is to programmatically change the constraints, but that’s probably beyond the scope of this question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I am obviously not a very good programmer. I have written this small
Can anyone please help me with this...I'm not very good with regular expressions and
Error:Exception in thread main java.lang.NullPointerException at com.vipgamming.Frytree.Game.main(Game.java:47) I am not a very good programmer.
I'm new to NHibernate and not very good at C#, but I'm learning. I
I'm not very good in SQL and HQL... I have two domains: class Hotel
I'm not very good at PHP and would like to have a PHP function
I'm not very good at regex but maybe there's a simple way to achieve
I'm not very good with Django's form . Here is Order from models.py class
I'm not familiar at all with JQuery and I'm not very good with CSS,
First off, I am not very good with MySQL yet, so go easy on

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.