开发者

creating an infinite stack of UIImageviews in xcode [duplicate]

This question already has answers here: Why can't variables be declared in a switch statement? (23 answers) Closed 2 years ago.

i am trying to create a stack of UIImageViews in my app where i can indefinitely touch the uiimageview move it around the screen and drop it anywhere and there would still be a representation of the UIImageview in the original location where i could go grab ano开发者_Python百科ther uiimageview move it and so on.the way i was trying to solve this problem was to create a uiimageview in IB that would remain in its original location and each time a touch is detected on top of it create a new uiimageview in the same location that would be able to be moved. here is the code i have so far:

-(void)dispatchTouchEvent:(UIView *)theView toPosition:(CGPoint)position
{

    switch (glyphActive) {
        case 1:
            UIImage *image = [UIImage imageNamed:@"1.png"];
            onePieceCopy = [[UIImage alloc] initWithImage:image];
            onePieceCopy.frame = CGRectMake(currentPos.x, currentPos.y, 75, 75);
            [self.view addSubview:image];
            if (CGRectContainsPoint([onePiece frame], position)) {
                onePiece.center = position;
                [self bringSubviewToFront:onePiece];
            } 
            //[onePieceCopy release];
            break;
        }
}

however i am getting errors on this line:

UIImage *image = [UIImage imageNamed:@"1.png"];

that says "expected expression before 'UIImage'". and another error here:

[self.view addSubview:image];

that says " error: request for member 'view' in something not a structure or union"

i'm fairly new to all this and im not sure what im doing wrong can anyone give me a hand?


well for one thing [self.view addSubview:image] should be [theView addSubview:image]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜