setImage-addSubview-发布
以下是 iPhone 的一些代码:
Controller.h:
IBOutlet UIImageView *userImage;
IBOutlet UIImageView *userImage2;
}
@property (nonatomic, retain) IBOutlet UIImageView *userImage;
@property (nonatomic, retain) IBOutlet UIImageView *userImage2;
Controller.m:
UIImageView *myImage2b = [[UIImageView alloc] initWithFrame:myImageRect4];
[myImage2b setImage:[UIImage imageNamed:@"RedPin.png"]];
[userImage2 addSubview:myImage2b];
[userImage2 release];
[myImage2b release];
我只是想从我的子视图中删除“RedPin”并重新使用 userImage2 作为将来的引脚。当然,发布后userImage2就无法访问了。这不是地图应用程序。任何想法都会有帮助。提前致谢。
Here is some code for iPhone:
Controller.h:
IBOutlet UIImageView *userImage;
IBOutlet UIImageView *userImage2;
}
@property (nonatomic, retain) IBOutlet UIImageView *userImage;
@property (nonatomic, retain) IBOutlet UIImageView *userImage2;
Controller.m:
UIImageView *myImage2b = [[UIImageView alloc] initWithFrame:myImageRect4];
[myImage2b setImage:[UIImage imageNamed:@"RedPin.png"]];
[userImage2 addSubview:myImage2b];
[userImage2 release];
[myImage2b release];
I am just trying to get rid of the "RedPin" from my Subview and re-use userImage2 for future pins. Of course, userImage2 is not accessible after the release. This is not a mapping app. Any ideas would be helpful. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我要做的就是在你的头文件中声明 userImage2 ,就像你一样。然后,无需在初始化后释放它,只需将其添加
到您的 dealloc 函数中,并
在您想从视图中删除图像时调用。
编辑:我似乎有点误读了你的帖子。如果您只想从 userImage2 中删除红色图钉,请使用:
What I would do is declare userImage2 in your header file., like you have. And then instead of releasing it after initializing it simply add the
to your dealloc function and call
whenever you want to remove the image from the view.
EDIT: I seem to have misread your post slightly. If you want to remove just the red pin from userImage2 use: