Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-21-2010, 05:51 AM   #1 (permalink)
Registered Member
 
Join Date: Aug 2009
Location: Bangalore, India
Posts: 5
heavenking is on a distinguished road
Thumbs up changing uiimageview position through selector

i'm trying to change the position of my image view after time delay like in the following code


Code:
 CGPoint pointOne=CGPointMake(150, 200);
	UIImageView *sampleImage=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"hello.png"]];
	[sampleImage performSelector:@selector(setCenter:) withObject:[NSValue valueWithCGPoint:pointOne] afterDelay:0.5];
it does not works properly because image view does not accept the nsvalue plz say any other solution to pass the cgpoint as the object. Thanks in advance.
heavenking is offline   Reply With Quote
Old 08-21-2010, 05:15 PM   #2 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 107
JDave is on a distinguished road
Default

A CGPoint is 'two' numbers, made up of two CGFloats (floats). It is an 'x' and a 'y'. You will need to wrap your selector with a larger statement like:
Code:
... withObject:CGPointMake([NSValue valueWithCGPoint:pointXOne] ,[NSValue valueWithCGPoint:pointYOne]) ...
JDave is offline   Reply With Quote
Old 08-21-2010, 06:40 PM   #3 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by heavenking View Post
i'm trying to change the position of my image view after time delay like in the following code


Code:
 CGPoint pointOne=CGPointMake(150, 200);
	UIImageView *sampleImage=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"hello.png"]];
	[sampleImage performSelector:@selector(setCenter:) withObject:[NSValue valueWithCGPoint:pointOne] afterDelay:0.5];
it does not works properly because image view does not accept the nsvalue plz say any other solution to pass the cgpoint as the object. Thanks in advance.
You can't pass non-object parameters using performSelector:withObject:afterDelay:

In order to do that, you'll need to create an additional method. Say you call it moveImage:


Code:
-(void) moveImage
{
  [sampleImage setCenter: CGPointMake(150, 200)];
}

...
  UIImageView *sampleImage=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"hello.png"]];
  [self performSelector: @selector(moveImage) withObject: nil afterDelay: 0.5];
There is another Cocoa feature called NSInvocation that lets you invoke an arbitrary method with any types of parameters much like the "performSelector" methods, but I haven't used it.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 08-24-2010, 04:54 AM   #4 (permalink)
Registered Member
 
Join Date: Aug 2009
Location: Bangalore, India
Posts: 5
heavenking is on a distinguished road
Smile thanks to duncan

Quote:
Originally Posted by Duncan C View Post
You can't pass non-object parameters using performSelector:withObject:afterDelay:

In order to do that, you'll need to create an additional method. Say you call it moveImage:


Code:
-(void) moveImage
{
  [sampleImage setCenter: CGPointMake(150, 200)];
}

...
  UIImageView *sampleImage=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"hello.png"]];
  [self performSelector: @selector(moveImage) withObject: nil afterDelay: 0.5];
There is another Cocoa feature called NSInvocation that lets you invoke an arbitrary method with any types of parameters much like the "performSelector" methods, but I haven't used it.
thanks duncan i agree your first way mostly i use this way only. but actually i want to avoid making additional methods for this thinks thats why i use the selector method. can you give a sample code for NSInvocation to pass non object arguments. Thanks in advance

Last edited by heavenking; 08-24-2010 at 05:00 AM.
heavenking is offline   Reply With Quote
Old 08-24-2010, 07:24 AM   #5 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Enschede, Netherlands
Posts: 198
rickrets is on a distinguished road
Default

NSInvocation Class Reference

Have a blast
rickrets is offline   Reply With Quote
Reply

Bookmarks

Tags
cgpoint, iphone sdk, nsvalue, selector, uiimageview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 343
5 members and 338 guests
freewind, HemiMG, lendo, Newbie123, PlutoPrime
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,894
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:55 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0