开发者

how to remove image for iphone

开发者 https://www.devze.com 2023-01-08 08:43 出处:网络
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { if ([[touch view] tag] == 1000) { tap=YES;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    if ([[touch view] tag] == 1000) 
    {
        tap=YES;
        NSLog(@"tap");
        //[yourButton setShowsTouchWhenHighlighted:YES];
        if(tap)
        {
            CGR开发者_StackOverflow中文版ect myImageRect = CGRectMake(p.x-113, p.y-113, 224.0f, 195.0f);
            myImagea = [[UIImageView alloc] initWithFrame:myImageRect];
            [myImagea setImage:[UIImage imageNamed:@"Enjoy Sunburst.png"]];
            myImagea.opaque = YES; // explicitly opaque for performance
            [self.view addSubview:myImagea];
            [myImagea release];                 
        }
        [pieMenu showInView:self.view atPoint:p]; 
}               
    else {
        NSLog(@" NO tap"); 
        // i want to remove image when user is not tapping
        //how to do that is myImagea.alpha=0 is the only options
    }
}


You can set the hidden property of the UIImageView to YES.

If you would actually want to remove it, you can call removeFromSuperview.


I'm going to assume your touch events code is correct...

To actually remove the object, you'd do something similar to this

[someObjectHere removeFromSuperview];

If you're trying to hide it, do what Jacob stated via the hidden property

0

精彩评论

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