English 中文(简体)
我如何在《国际不动产业联合会意见》上建立可移动的标签?
原标题:How do I create movable labels on a UIView?

我正试图在<条码>查询/编码>上建立四个可移动的标签。

当我打上<条码>时 他们都聚集在一个地点,我无法接触或移动其他标签。

是否有任何人知道我的四个标签是这样行事的?

我添加了另外4个标签,显示分解的x和 y坐标。

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{   


UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:self.view];

    if ([touch view] == ifAnimPart01){
        ifAnimPart01.center = location;
    }   
    else if ([touch view] == ifAnimPart02){
        ifAnimPart02.center= location;
    }   
    else if ([touch view] == ifAnimPart03){
        ifAnimPart03.center= location;
    }
    else if ([touch view] == ifAnimPart04){
        ifAnimPart04.center= location;
    }

}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
    [self touchesBegan:touches withEvent:event];

    UITouch *myTouch = [touches anyObject];
    startPoint1 = [myTouch locationInView:self.view];
    xCoordLabel1.text = [NSString stringWithFormat:@"Line OneX = %f", startPoint1.x];
    yCoordLabel1.text = [NSString stringWithFormat:@"Line OneY = %f", startPoint1.y];
    ifAnimPart01.center = CGPointMake(startPoint1.x, startPoint1.y);

    startPoint2 = [myTouch locationInView:self.view];
    xCoordLabel2.text = [NSString stringWithFormat:@"Line TwoX = %f", startPoint2.x];
    yCoordLabel2.text = [NSString stringWithFormat:@"Line TwoY = %f", startPoint2.y];
    ifAnimPart02.center = CGPointMake(startPoint2.x, startPoint2.y);

    startPoint3 = [myTouch locationInView:self.view];
    xCoordLabel3.text = [NSString stringWithFormat:@"Line ThreeX = %f", startPoint3.x];
    yCoordLabel3.text = [NSString stringWithFormat:@"Line ThreeY = %f", startPoint3.y];
    ifAnimPart03.center = CGPointMake(startPoint3.x, startPoint3.y);

    startPoint4 = [myTouch locationInView:self.view];
    xCoordLabel4.text = [NSString stringWithFormat:@"Line FourX = %f", startPoint4.x];
    yCoordLabel4.text = [NSString stringWithFormat:@"Line FourY = %f", startPoint4.y];
    ifAnimPart04.center = CGPointMake(startPoint4.x, startPoint4.y);
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{

}
问题回答

暂无回答




相关问题
iPhone view is 3/4 grey, could be rotated incorrectly

This problem has just come up when I cleaned all targets and soft resetted (held home & power for about 10 seconds) my iPod Touch (2nd gen). It looks like the view might be rotated portrait. Here ...

iPhone + clear all UI Controls from View

I have a view in which I have few labels and I want to dynamically clear the view (remove all the labels) at certain condition in my application. Please help me Regards, Pratik

Calling another view from within a view class

i may be making more out of this because of the late hour. i am confused. i have multiple views i call from a viewcontroller class. typically they are called with a uibutton object. say i have two ...

iPhone SDK: repeat subviews

I have one UIView, which I m using as my main view, and I want to repeat the subview across the screen. How exactly can I do this?

热门标签