iphone - Manually passing touches Began to a newly created instance -


i want object created when touch uiview. want new object able moved without finger having raised. tried passing touched event new object doesn't work.

is there way it?

you'll have derive subclass of uiview, serve holderview newly generated views. also, once new view generated, new view move along finger if not raised.

following code it, tweak later per needs:

@interface holderview : uiview  @property(nonatomic,retain)uiview *newview;  @end  @implementation holderview  - (id)initwithframe:(cgrect)frame {     self = [super initwithframe:frame];     if (self) {         // initialization code     }     return self; }    -(void)touchesbegan:(nsset *)touches withevent:(uievent *)event {     uitouch *touch = [touches anyobject];     cgpoint touchpoint = [touch locationinview:self];      if (cgrectcontainspoint(self.bounds, touchpoint)) {          cgrect r = cgrectmake(touchpoint.x-50, touchpoint.y-50, 100, 100);          self.newview = [[[uiview alloc] initwithframe:r]autorelease];         self.newview.backgroundcolor= [uicolor cyancolor];         [self addsubview:self.newview];      } }   -(void)touchesmoved:(nsset *)touches withevent:(uievent *)event {     if (self.newview!=nil) {         uitouch *touch = [touches anyobject];         cgpoint touchpoint = [touch locationinview:self];         self.newview.center = touchpoint;     } }  @end 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -