7

में जेस्चर रिकॉग्नाइज़र खोना मेरे पास PhotoBoothController नामक एक क्लास है जिसका उपयोग मैं इशारा करते हुए एक छवि में हेरफेर करने के लिए करता हूं। जब मैं इसे आईफोन पर चलाता हूं तो यह ठीक काम करता है। हालांकि जब मैं इसे आईपैड पर चलाता हूं, तो मैं एक यूआईपीओवर कंट्रोलर के अंदर फोटोबुथ कंट्रोलर प्रदर्शित करता हूं। छवि ठीक दिखाई देती है, हालांकि मैं इसे छेड़छाड़ नहीं कर सकता क्योंकि मेरे इशारे को पहचाना नहीं जा रहा है। मुझे यकीन नहीं है कि UIPopoverController जेस्चर का नियंत्रण कैसे ले सकता है।UIPopoverController

मैं popovercontroller प्रस्तुत करते हैं और इस प्रकार दृश्य को कॉन्फ़िगर:

- (void)presentPhotoBoothForPhoto:(UIImage *)photo button:(UIButton *)button { 

    //Create a photoBooth and set its contents 
    PhotoBoothController *photoBoothController = [[PhotoBoothController alloc] init]; 
    photoBoothController.photoImage.image = [button backgroundImageForState:UIControlStateNormal]; 

    //set up all the elements programmatically. 
    photoBoothController.view.backgroundColor = [UIColor whiteColor]; 

    //Add frame (static) 
    UIImage *frame = [[UIImage imageNamed:@"HumptyLine1Frame.png"] adjustForResolution]; 
    UIImageView *frameView = [[UIImageView alloc] initWithImage:frame]; 
    frameView.frame = CGRectMake(50, 50, frame.size.width, frame.size.height); 
    [photoBoothController.view addSubview:frameView]; 

    //Configure image 
    UIImageView *photoView = [[UIImageView alloc] initWithImage:photo]; 
    photoView.frame = CGRectMake(50, 50, photo.size.width, photo.size.height); 
    photoBoothController.photoImage = photoView; 

    //Add canvas 
    UIView *canvas = [[UIView alloc] initWithFrame:frameView.frame]; 
    photoBoothController.canvas = canvas; 
    [canvas addSubview:photoView]; 
    [canvas becomeFirstResponder]; 

    [photoBoothController.view addSubview:canvas]; 
    [photoBoothController.view bringSubviewToFront:frameView]; 

    //resize the popover view shown in the current view to the view's size 
    photoBoothController.contentSizeForViewInPopover = CGSizeMake(frameView.frame.size.width+100, frameView.frame.size.height+400); 

    self.photoBooth = [[UIPopoverController alloc] initWithContentViewController:photoBoothController]; 
    [self.photoBooth presentPopoverFromRect:button.frame 
            inView:self.view 
        permittedArrowDirections:UIPopoverArrowDirectionAny 
            animated:YES]; 
} 

मैंने सोचा था कि [canvas becomeFirstResponder] यह कर सकता है, लेकिन यह एक फर्क प्रतीत नहीं होता है।

कोई सलाह बहुत सराहना करता है, धन्यवाद।

अद्यतन: टिप्पणी के अनुसार कोड जोड़ने

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    if (!_marque) { 
    _marque = [CAShapeLayer layer]; 
    _marque.fillColor = [[UIColor clearColor] CGColor]; 
    _marque.strokeColor = [[UIColor grayColor] CGColor]; 
    _marque.lineWidth = 1.0f; 
    _marque.lineJoin = kCALineJoinRound; 
    _marque.lineDashPattern = [NSArray arrayWithObjects:[NSNumber numberWithInt:10],[NSNumber numberWithInt:5], nil]; 
    _marque.bounds = CGRectMake(photoImage.frame.origin.x, photoImage.frame.origin.y, 0, 0); 
    _marque.position = CGPointMake(photoImage.frame.origin.x + canvas.frame.origin.x, photoImage.frame.origin.y + canvas.frame.origin.y); 
    } 
    [[self.view layer] addSublayer:_marque]; 

    UIPinchGestureRecognizer *pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(scale:)]; 
    [pinchRecognizer setDelegate:self]; 
    [self.view addGestureRecognizer:pinchRecognizer]; 

    UIRotationGestureRecognizer *rotationRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotate:)]; 
    [rotationRecognizer setDelegate:self]; 
    [self.view addGestureRecognizer:rotationRecognizer]; 

    UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)]; 
    [panRecognizer setMinimumNumberOfTouches:1]; 
    [panRecognizer setMaximumNumberOfTouches:1]; 
    [panRecognizer setDelegate:self]; 
    [canvas addGestureRecognizer:panRecognizer]; 

    UITapGestureRecognizer *tapProfileImageRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)]; 
    [tapProfileImageRecognizer setNumberOfTapsRequired:1]; 
    [tapProfileImageRecognizer setDelegate:self]; 
    [canvas addGestureRecognizer:tapProfileImageRecognizer]; 

} 

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { 
    return ![gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && ![gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]; 
} 
+0

कृपया अपने UIPopoverController – Stavash

+0

@stavash करने के लिए जेस्चर पहचानकर्ता को संलग्न करने के लिए उपयोग किया गया कोड जोड़ें - कोड PhotoBoothController क्लास में है। धन्यवाद! – Smikey

+0

यह एक दिलचस्प मुद्दा है। UIPopoverController को बाहरी रूप से जेस्चर जोड़ने के बारे में कैसे? मुझे पता है कि इसमें कुछ बदलाव की आवश्यकता है लेकिन मेरे पास अभी कोई अन्य सुझाव नहीं है ... – Stavash

उत्तर

1

कुछ अनुमान:

  1. इस वजह viewDidLoad विधि cavas संपत्ति का गठन किया गया से पहले बुलाया गया है है? इस मामले में, आप viewDidAppear जैसे किसी अन्य विधि में वर्तमान पॉपओवर के बाद पहचानकर्ताओं को जोड़ने का प्रयास कर सकते हैं।

  2. मैं यह भी मानता हूं कि कुंजी यह हो सकती है कि UIPopoverController पॉपओवर के बाहर अन्य विचारों पर बातचीत की अनुमति देता है। इसलिए मैं [canvas becomeFirstResponder]; को viewDidLoadPhotoBoothController में विधि के अंत में ले जाने का सुझाव देता हूं और यहां self.view becomeFirstResponder आजमाएं क्योंकि आप वास्तव में self.view में पहचानकर्ता जोड़ते हैं।

3

मैं एक समान आवेदन पर काम कर रहा हूं, और मैं आसानी से कैनवास पर छवियों का उपयोग कर सकता हूं।

1) देखें कि क्या userInteractionEnabled कैनवास के संपत्ति हाँ को तैयार है।
2) आप कैनवास के बजाय इमेज व्यू में जेस्चर जोड़ने का प्रयास कर सकते हैं। (मुझे लगता है कि आप ज़ूम करना चाहते हैं, एन घुमाएं छवियों को स्वाइप करें)।