1
Я поместил свою функцию share в файл ShareViewController.swift
, он отлично работает в iPhone-симуляторе, но он выходит из строя и закрывает симулятор, когда я запускаю его в симуляторе iPad2. , пожалуйста, помогите дать ан. с каждым шагом. Спасибо!swift share работает в iphone, но ошибка в ipad2
import UIKit
class ShareViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
let firstActivityItem = "share it!"
let activityViewController : UIActivityViewController = UIActivityViewController(activityItems: [firstActivityItem], applicationActivities: nil)
self.presentViewController(activityViewController, animated: true, completion: nil)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
Сообщение об ошибке:
2015-07-16 13:35:06.293 pages[2539:46687] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'UIPopoverPresentationController (<_UIAlertControllerActionSheetRegularPresentationController: 0x797fb2c0>) should have a non-nil sourceView or barButtonItem set before the presentation occurs.'
*** First throw call stack:
(
0 CoreFoundation 0x0027c746 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x01d10a97 objc_exception_throw + 44
2 UIKit 0x0135aee2 -[UIPopoverPresentationController presentationTransitionWillBegin] + 3086
3 UIKit 0x00c71124 __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke + 1549
4 UIKit 0x00c6f1f7 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 198
5 UIKit 0x00ca42cb __40+[UIViewController _scheduleTransition:]_block_invoke + 18
6 UIKit 0x00b5d812 ___afterCACommitHandler_block_invoke + 15
7 UIKit 0x00b5d7bd _applyBlockToCFArrayCopiedToStack + 415
8 UIKit 0x00b5d5d2 _afterCACommitHandler + 549
9 CoreFoundation 0x0019d86e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
10 CoreFoundation 0x0019d7b0 __CFRunLoopDoObservers + 400
11 CoreFoundation 0x001931ea __CFRunLoopRun + 1226
12 CoreFoundation 0x00192a5b CFRunLoopRunSpecific + 443
13 CoreFoundation 0x0019288b CFRunLoopRunInMode + 123
14 GraphicsServices 0x03f1e2c9 GSEventRunModal + 192
15 GraphicsServices 0x03f1e106 GSEventRun + 104
16 UIKit 0x00b330b6 UIApplicationMain + 1526
17 pages 0x0004eb74 main + 180
18 libdyld.dylib 0x02406ac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
проверить это;) http://stackoverflow.com/questions/25644054/uiactivityviewcontroller-crashing -он-ios8-Ipads –