image move in IPhone


In this tutorial we will see the app is how the image move in view. This is the view based app.Here are some steps for it…

 

 

1. Open the xcode & choose "File->New Project".

2. Select "Application" from left menu and then "View-based Application".

3.Name your project as "imagemov" and save the project.

4.Now just select "imagemovViewController.h" file from left menu for define a      UIImageView . Set the property for UIImageView.


 

#import <UIKit/UIKit.h>


@interface imagemovViewController : UIViewController {

UIImageView *imageOne;

UIImageView *imageTwo;

}

@property(nonatomic,retain)UIImageView *imageOne;

@property(nonatomic,retain)UIImageView *imageTwo;

@end

 

 

5. Now select "imagemovViewController.m" file from menu for implementation.

 

 

#import "imagemovViewController.h"


@implementation imagemovViewController


@synthesize imageOne,imageTwo;

- (void)viewDidLoad {

    [super viewDidLoad];

UIImage *imgone=[UIImage imageNamed:@"Mystery.jpg"];

imageOne=[[UIImageView alloc]initWithImage:imgone];

[imageOne setFrame:CGRectMake(110, 60, [imageOne frame].size.width,[imageOne frame].size.height)];


[self.view addSubview:imageOne];

[imageOne release];

UIImage *imgTwo=[UIImage imageNamed:@"Happy Face.gif"];

imageTwo=[[UIImageView alloc]initWithImage:imgTwo];

[imageTwo setFrame:CGRectMake(110, 200, [imageTwo frame].size.width,[imageTwo frame].size.height)];

[self.view addSubview:imageTwo];

[imageTwo release];

}


- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event

{

if ([touches count] == 1) {

CGPoint newTouch = [[touches anyObject] locationInView:[self view]]; 

CGPoint lastTouch = [[touches anyObject] previousLocationInView: [self view]];

float xDif = newTouch.x - lastTouch.x

float yDif = newTouch.y - lastTouch.y;

CGAffineTransform translate = CGAffineTransformMakeTranslation(xDif, yDif);

imageOne.transform= CGAffineTransformConcat(imageOne.transform, translate);

imageTwo.transform= CGAffineTransformConcat(imageTwo.transform, translate);


}


- (void)dealloc {

    [super dealloc];

}


@end

 

6. Now double click on "imagemovViewController.xib" from Resource folder for open it.


7. On the view window drag the UIImageView from library . Then link the UIImageView  to the File's Owner. 


8. Then Quit and Save the Interface Builder.


9. Now you are ready for  click on "Build & Go" button. 


Now you can see the output in iphone simulator .


 



(9) Responses to this post

Lorrie May 05 2011 at 00:36:57

At last, someone comes up with the "right" anwser!

pmqqzo May 05 2011 at 06:57:20

5DJFfq eeqocwnatokx

ujtumh May 06 2011 at 06:09:19

eYjCri , [url=http://dfpdoauqodkl.com/]dfpdoauqodkl[/url], [link=http://nzadplzecgek.com/]nzadplzecgek[/link], http://zlvcpuhqspdf.com/

avbkmooeau Jul 24 2011 at 15:51:52

Windows 7 wireless access problems?Java Malfunction. My Java won't "work." Can anyone help?dr java help with turning light to green?Which type of MYSQL queries should be cached ? My headphones aren't working? zgaga dieta How do yo

SweetKattyQQ Aug 01 2011 at 08:56:23

Microsoft Access question ("adding auto date")?Can i install Microsoft Expressions on two different computers?SPSS question - sorting data into new column?Does the mouse hunt toolbar work if you are not logged into facebook?

SweetKattyQQ Aug 02 2011 at 05:42:01

How long does it take to get paid on Amazon Mechanical Turk?Someone with a 192.com account?What exactly is an AutoCAD technician?Why are iPhone pictures small when I add them to Windows Movie Maker? What is the security rating for mic

SweetKattyQQ Aug 03 2011 at 02:52:57

Any good PHP forums to find help and interesting code?Why does a different printer default AFTER I change it in my system settings (Mac)?I need help with pcsx2 emulaor?File Host with sharing options for only one download then it is deleted?

KatQaNicee Aug 14 2011 at 09:40:04

What philosophical principle did Google’s managers adopt when deciding that the benefits of operating in China?Looping battle program in Java?Help me debug this! Please! ?How can I get my iPhone data on to a new laptop? ps3 slim 160gb what is the

sxqerdfccmafuueres Sep 20 2011 at 09:36:38

cheap xrumer service cheap backlinks cheap backlinks forum profiles service best xrumer service best xrumer service


Leave your comment here






User Login




New User Forgot password

Newsletter Subscribe

Advertisement

 
 
 
quick contact