私はドラッグアンドドロップアプリに取り組んでいます。ユーザーが画像をドロップすると、その画像からドラップポイントにコピーを作成したいのですが、元の画像が最初のポイントに戻ります。touchesEndedを実行した後、ビューコントローラにuiimageviewを追加することにしました。
メソッドを含むドラッグビュークラスがあります:
- (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は正しく機能します
解決策はありますか?