1
我正在处理拖放应用程序,当用户拖放图像时,我想从拖动点中复制它,然后原始图像返回到初始点。 我决定执行touchesEnded后的UIImageView添加到我的ViewController,将子视图添加到选择器中的主要uiview中
我有一个包含该方法拖动视图类:
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint activePoint = [[touches anyObject] locationInView:self];
UIImageView *myimage;
myimage.image = self.image;
myimage.center = activePoint;
ViewController *cview ;
cview = [[ViewController alloc]init];
[cview getpoint: myimage];
}
现在,在视图控制器,这是用GetPoint选择器:
-(void) getpoint : (UIImageView *) mine{
UIImageView *newimage;
newimage = mine;
[self.view addSubview:newimage];
NSLog(@" in getpoint");
}
当我放弃物体时,出现此错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
但是当我删除addsubview语句时,NSlog正在向右
任何解决方案?
我已经试过这可惜它没有工作 – Felwah 2013-02-16 11:44:55
您是否提供了的CGRect具有适当大小到您的UIImageView initWithFrame:?你确定你传递的图像不是零吗?当你说“它没有用”时,你能详细说明你的意思吗? – 2013-02-16 16:23:02