Tags
ios , xcode
Asked 8 years ago
4 Nov 2016
Views 1450
iPhone-coder

iPhone-coder posted

Error - Expression is not assignable , making draggable image in view


 
- (void) touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    UITouch *touch = [touches anyObject];
    CGPoint currentpoint = [touch locationInView:self.view];
    self.image1.center.x = currentpoint.x;
}


i want draggable image so i made code above and i got error when i setting center of image to current point of touchMoved
error is Expression is not assignable
ravi

ravi
answered Nov 30 '-1 00:00

or you can use direct like this


self.image1.center==CGPointMake(currentpoint.x, currentpoint.y);
Mitul Dabhi

Mitul Dabhi
answered Nov 30 '-1 00:00


    self.image1.center.x = currentpoint.x;

you can set directly image centre x by direct assigning value . you need to use setter method to do it .
you can use reference to change the value


   CGPoint _imagecenter = self.image1.center.x ;
    _imagecenter =CGPointMake(currentpoint.x, currentpoint.y);
self.image1.center = _imagecenter;


hope it help
Post Answer