กรณีนี้สร้างปุ่ม login จาก facebook sdk version 4.14.0 โดยใช้คลาส FBSDKLoginButton หลังจากสร้างเสร็จและทดสอบรัน กดปุ่ม login ก็จะเข้าสู่โหมด login ปุ่มจะกลายเป็น logout เมื่อเรากดปุ่ม logout จะต้องมี alertbox เด้งขึ้นมาเป็นปุ่มให้เลือกกดระหว่าง logout กับ cancel ตามรูปด้านบน แต่กรณีนี้จะเกิด error เหมือนจะเกิดเฉพาะกับ ipad นะครับ เพราะผมใช้ทดสอบกับ ipad ตามข้อความข้างล่างนี้เลยครับ
1 2 3 4 5 |
2016-08-23 16:37:38.115 FBLoginSwift[1505:1087947] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Your application has presented a UIAlertController () of style UIAlertControllerStyleActionSheet. The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem. If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.' *** First throw call stack: (0x18234adb0 0x1819aff80 0x187ded268 0x187801fb0 0x1878000c8 0x1877530c8 0x187760a80 0x1874925a4 0x182300728 0x1822fe4cc 0x1822fe8fc 0x182228c50 0x183b10088 0x18750a088 0x100006294 0x181dc68b8) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb) |
วิธีแก้ไขให้แก้ไขตามนี้ครับ
ที่มา : https://github.com/facebook/facebook-ios-sdk/pull/837/commits/5cd16f6e2c0a43aa6225da421b66811a13e91359
0