0 memory iphone cocoa objective-c uiimageview
我试图在touchesBegan方法中创建一个名为theImageView的UIImageView ,然后我可以移动到touchesMoved中的新位置.目前我在touchesMoved中收到"未声明"错误,我在其中设置了ImageView的新位置.
我该怎么做才能在这两种方法之间将ImageView保存在内存中?
编辑:我无法在@interface中声明图像视图,因为我需要在每次触摸某个点时创建图像.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
...
UIImageView *theImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]];
theImageView.frame = CGRectMake(263, 228, 193, 300);
[theImageView retain];
...
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
...
theImageView.frame = CGRectMake(300, 300, 193, 300);
...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
253 次 |
| 最近记录: |