내 ActionSheet에 큰 문제가 있습니다. 아이폰에 그것은 잘 작동하지만, 아이 패드에 그것은 단지 내가 그것을 작동 아이폰에 말했듯이 Swift UIAlertController -> ActionSheet iPad iOS8이 충돌 함 현재
내가 하나 개의 버튼import UIKit
extension ViewController : UIActionSheetDelegate {
func actionSheet(actionSheet: UIActionSheet, didDismissWithButtonIndex buttonIndex: Int) {
if actionSheet.tag == 0 {
if buttonIndex == 1 {
// doing something for "product page"
} else if (buttonIndex == 2) {
// doing something for "video"
}
}
}
}
class ViewController: UIViewController, UIActionSheetDelegate {
@IBAction func test(sender: AnyObject) {
let systemVersion: NSInteger = (UIDevice.currentDevice().systemVersion as NSString).integerValue
if systemVersion < 8 {
// iOS7:
let action:UIActionSheet = UIActionSheet(title: "Change Map Type", delegate: self, cancelButtonTitle: "Back", destructiveButtonTitle: nil, otherButtonTitles: "Product Page", "Video")
action.tag = 0
action.showInView(self.view)
} else {
// iOS8:
let alertController: UIAlertController = UIAlertController(title: "Change Map Type", message: nil, preferredStyle: UIAlertControllerStyle.ActionSheet)
let cancelAction: UIAlertAction = UIAlertAction(title: "Back", style: UIAlertActionStyle.Cancel, handler: nil)
let button1action: UIAlertAction = UIAlertAction(title: "Product Page", style: UIAlertActionStyle.Default, handler: { (action: UIAlertAction!) ->() in
// doing something for "product page"
})
let button2action: UIAlertAction = UIAlertAction(title: "Video", style: UIAlertActionStyle.Default, handler: { (action: UIAlertAction!) ->() in
// doing something for "video"
})
alertController.addAction(cancelAction)
alertController.addAction(button1action)
alertController.addAction(button2action)
self.presentViewController(alertController, animated: true, completion: nil)
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
}
와 함께 새로운 프로젝트를 생성 충돌,하지만 난 아이 패드상의 버튼을 클릭하면 54 : 52.784 테스트 [9541 : 1,970,048] * 종료 앱 인해 캐치되지 않는 예외 'NSGenericException'에 이유 : 앱
2014년 9월 25일 14 충돌 '애플리케이션 가 UIAlertController을 제시하고있다() 스타일 UIAlertControllerStyleActionSheet. 의 modalPresentationStyle 및이 스타일의 UIAlertController는 UIModalPresentationPopover입니다. 은 경고 컨트롤러의 popoverPresentationController를 통해이 팝업에 대한 위치 정보를 제공해야합니다. sourceView 및 sourceRect 또는 barButtonItem 중 하나를 으로 제공해야합니다. 알림 컨트롤러를 표시 할 때이 정보가 알 수없는 경우 인 경우 UIPopoverPresentationControllerDelegate 메서드 -prepareForPopoverPresentation에 제공 할 수 있습니다. * 우선 투사 호출 스택 (0 CoreFoundation에서 0x00613df6 exceptionPreprocess 182 + 1 libobjc.A.dylib
0x01fdaa97 objc_exception_throw + 44 2 UIKit
0x0164da37 - [UIPopoverPresentationController presentationTransitionWillBegin] + (3) 3086 UIKit
0x00f54f75 __71- [UIPresentationController _initViewHierarchyForPresentationSuperview :] _ block_invoke + 1,666 4 UIKit 0x00f53554 __56- [UIPresentationController runTransitionForCurrentState] _block_invoke + 226 5 UIKit
0x00f8721b __40 + [UIViewController에 _scheduleTransition :] + _ block_invoke 18 6 UIKit의 0x00e4d62e ___afterCACommitHandler_block_invoke + 15 7 UIKit 0x00e4d5d9 _applyBlockToCFArrayCopiedToStack + 415 8 UIKit
0x00e4d3ee _afterCACommitHandler + 545 9 CoreFoundation에서
0x00536fbe __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 30 10 CoreFoundation에서 0x00536f00 __CFRunLoopDoObservers + 400 11 CoreFoundation에서의 0x0052c93a __CFRunLoopRun + 1,226 12 CoreFoundation에서 0x0052c1ab CFRunLoopRunSpecific + 443 13 CoreFoundation
0x0052bfdb CFRunLoopRunInMode + 123 14 그래픽 서비스
0x0438424f GSEventRunModal + 192 15 GraphicsServices
,0x0438408c GSEventRun + 104 16 UIKit
0x00e23e16 UIApplicationMain 1,526 + 17 시험
0x00085e9e top_level_code + 78 18 테스트
0x00085edb 메인 + 43 19 libdyld.dylib
시작 0x0273eac9 + 1 20 ???
0x00000001이 0x0 + 1)의 libC++ abi.dylib : 다운로드 https://www.dropbox.com/s/54jqd8nsc67ll5g/test.zip?dl=0에서 찾을 시도 할 수 있습니다 유형 NSException
프로젝트의 캐치되지 않는 제외하고 종료.
포스트 내 대답과 아주 비슷합니다 ... 예외는 예외입니다. http://stackoverflow.com/questions/26037657/swift-uiactionsheet-crashes-on-ipad – holex
네, 그래도 여전히 충돌합니다 –
곧 내 대답을 업데이트 할 것입니다 ... – holex