Saturday, 20 April 2013

Define and Move the Objects in Xcode

Step 1: Create a Project.

Step 2: Add the images into your project.

Step 3: In .h File Add the Codings are,

#import <UIKit/UIKit.h>

@interface Touchviewcontroller : UIViewController
{
    
}

-(IBAction)handlePan:(UIPanGestureRecognizer *)recognizer;

@end

Step 4: In .m File Add the Codings are,

-(IBAction)handlePan:(UIPanGestureRecognizer *)recognizer
{
    CGPoint translation = [recognizer translationInView:self.view];
    recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x,
                                         recognizer.view.center.y + translation.y);
    [recognizer setTranslation:CGPointMake(00inView:self.view];
}

Step 5: In Xib File (Design)

  * Create a Image View  and  assign the image.

  * PanGestureRecognizer drag&drop to Image View.
  
  * FileOwner --> Outlets --> Map the handlePan to PanGestureRecognizer.


 
















Step 7: Build and Run the application. You can Select and move objects.


No comments: