2012-10-26 12 views
7

मैं UIActivityViewController का उपयोग करके अपने ऐप में नई आईओएस 6 साझा करने की कार्यक्षमता जोड़ने की कोशिश कर रहा हूं। मेरे पास कुछ पाठ है जो मैं साझा करना चाहता हूं और यदि वे ईमेल चुनते हैं तो मैं स्वचालित रूप से ईमेल के विषय को भी सेट करना चाहता हूं। iOS6 के साथ एक iPad 2 परUIActivityViewController क्रैशिंग, NSCFConstantString _beforeActivity अज्ञात चयनकर्ता उदाहरण के लिए भेजा गया

[694:907] items=(
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas porttitor accumsan mi eu mollis. Fusce condimentum dictum lectus, eu ultrices urna vulputate eu." 
) 
[694:907] -[__NSCFConstantString _beforeActivity]: unrecognized selector sent to instance 0x3ad971c8 
[694:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString _beforeActivity]: unrecognized selector sent to instance 0x3ad971c8' 
*** First throw call stack: 
(0x35add2a3 0x37a1497f 0x35ae0e07 0x35adf531 0x35a36f68 0x361dc7a3 0x361dc52d 0x36067595 0x36434d31 0x3642fe07 0x2990b 0x361330ad 0x36133135 0x361330ad 0x3613305f 0x3613303d 0x361328f3 0x36132de9 0x3605b5f9 0x36048809 0x36048123 0x37bd15a3 0x37bd11d3 0x35ab2173 0x35ab2117 0x35ab0f99 0x35a23ebd 0x35a23d49 0x37bd02eb 0x3609c301 0x1ef9d 0x1ef30) 
libc++abi.dylib: terminate called throwing an exception 

मैं इस चल रहा हूँ:

NSArray *activityItems = @[resultString]; 
NSLog(@"items=%@", activityItems); 

NSArray *acitivities = @[UIActivityTypeMail, UIActivityTypeMessage, UIActivityTypePrint, UIActivityTypePostToFacebook, UIActivityTypeCopyToPasteboard]; 

UIActivityViewController *activityController = 
    [[UIActivityViewController alloc] initWithActivityItems:activityItems 
             applicationActivities:activities]; 

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 
    self.popover = [[UIPopoverController alloc] initWithContentViewController:activityController]; 
    // the line above is where the error happens. 
    [self.popover presentPopoverFromBarButtonItem:self.emailResultsButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 
} else { 
    [self presentViewController:activityController 
         animated:YES 
        completion:nil]; 
} 

त्रुटि संदेश सहित कोड के उत्पादन में है। कोई विचार?

संपादित करें: ऐसा प्रतीत होता है कि यदि मैं गतिविधियों की सरणी नहीं देता तो सब कुछ ठीक काम करता है। अभी भी समस्या को कम कर रहा है।

+0

यदि आप एआरसी बंद करते हैं तो क्या समस्या बनी रहती है? (मैं हां भविष्यवाणी करता हूं) –

+0

एआरसी बंद करना एक स्विच फिसलने जैसा नहीं है ... लेकिन मैंने चारों ओर खेलना जारी रखा है। ऐसा लगता है कि जब मैं गतिविधियों सरणी प्रदान नहीं करता हूं तो समस्या दूर हो जाती है। –

+0

अच्छी तरह से, बस संकलक ध्वज अस्थायी रूप से बंद करें। स्मृति रिसाव पर ध्यान मत दो। –

उत्तर

16

अपवाद यह सब कहते हैं:

NSArray *acitivities = @[UIActivityTypeMail, UIActivityTypeMessage, UIActivityTypePrint, UIActivityTypePostToFacebook, UIActivityTypeCopyToPasteboard]; 

प्रलेखन कहते विधि UIActivity वस्तुओं की एक सूची की उम्मीद:

applicationActivities

आप तार की एक सरणी में गुजर रहे हैं

यूआईएक्टिविटी ऑब्जेक्ट्स की एक सरणी जो आपके एप्लिकेशन का समर्थन करती है, उस कस्टम सेवाओं का प्रतिनिधित्व करती है। यह पैरामीटर शून्य हो सकता है।

ध्यान दें कि यह कस्टम गतिविधियों के लिए है, जैसे यदि आप मौजूदा सेवाओं के अतिरिक्त अपने ड्रॉपबॉक्स एकीकरण की पेशकश करना चाहते हैं।

संपादित करें: गतिविधि प्रकार का सवाल है, वे केवल UIActivity.activityType, UIActivityItemProvider.activityType, UIActivityViewController.excludedActivityTypes, और -[UIActivityItemSource activityViewController:itemForActivityType:] में इस्तेमाल किया जा दिखाई देते हैं।

+0

आआंद हमारे यहां एक विजेता है! +1। –

+0

धन्यवाद, वह था। अब मुझे यह पता लगाना होगा कि फेसबुक सूची में क्यों नहीं दिख रहा है। शायद मैं इस डिवाइस पर फेसबुक में लॉग इन नहीं हूं। –

+4

मेरी इच्छा है कि ओब्जेसी ने Arrays टाइप किया था, इसलिए हमें यह समस्या नहीं होगी। NSArray इसे पूरी तरह से टालना होगा। –

संबंधित मुद्दे

 संबंधित मुद्दे