배경 :iOS의 UIPanGestureRecognizer의 선택자에서보기의 컨트롤러를 참조하는 방법은 무엇입니까?
내가 MVC 기반 폴라로이드 개체가 있습니다. 모델은 사진의 메타 데이터 및 이미지를 유지합니다. 보기에는 사진의 이름과 이미지가 UIView를 통해 표시됩니다. 컨트롤러는 모델과 뷰에 대한 액세스 권한을 가지고 있으며, 그들 사이에 (보기에 예를 들어, 페이드의 모델 사진.)
내 목표 작업을 조정 : 제가 구현하려는
간단한 드래그 앤를 드롭 기능을 사용하여 사용자가 polarid의 뷰를 드래그하여 뷰 컨트롤러을 앨범으로 드래그 할 수 있습니다.
문제 : 내 폴라로이드의보기로 UIPanGestureRecognizer을 추가 할 수있어
. 그러나, 나는 polaroidPanned 메서드에서 viewcontroller 또는 모델에 액세스 할 수 없습니다. UIPanGestureRecognizer 추가
:UIPanGestureRecognizer *panRecogniser = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(polaroidPanned:)];
[polaroidController.polaroidView addGestureRecognizer:panRecogniser];
다음은 UIPanGestureRecognizer 핸들러의 :
- (void) polaroidPanned: (UIPanGestureRecognizer *) panGesture
{
CGPoint touchLocation = [panGesture locationInView:self.view];
//While being dragged
if ([panGesture state] == UIGestureRecognizerStateBegan || [panGesture state] == UIGestureRecognizerStateChanged)
{
//update the album view to the touch location
[panGesture view].center = touchLocation;
}
else if ([panGesture state] == UIGestureRecognizerStateEnded && isOntopOfAlbum)
{
//HERE I WANT TO PASS THE VIEW CONTROLLER OF THE [panGesture view] to my album
[album addPolaroidViewController: ????]
}
}
내가보기를 통과 할 수 있어요,하지만 난 뷰의의 ViewController를 참조 할 수없는 것.
아무도 내가 이것을 수행 할 수있는 방법을 알고 있습니까? 아니면 해결할 수 있을까요?