gpt4 book ai didi

ios - 社交媒体应用程序的按钮不起作用 - Swift

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:12:50 24 4
gpt4 key购买 nike

<分区>

我目前正在制作一个应用程序,我正在使用带有 Xcode 8.2 beta 的 Swft 3。我正在努力做到这一点,以便用户能够从我的 iOS 项目中的 SWRevealViewController 访问社交媒体。当点击社交媒体按钮时,他们应该打开相应的应用程序。但是,当执行代码并打开 iOS 模拟器时,当我滑动打开 SWRevealViewController(菜单)时,应用程序崩溃了。

完整错误信息:

 *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<TheGunnOracleApp.SocialMedia 0x7ffd0d50c0d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key dataSource.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010212dd4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000101b8f21e objc_exception_throw + 48
2 CoreFoundation 0x000000010212dc99 -[NSException raise] + 9
3 Foundation 0x000000010169db3f -[NSObject(NSKeyValueCoding) setValue:forKey:] + 291
4 UIKit 0x0000000102e8e99f -[UIViewController setValue:forKey:] + 88
5 UIKit 0x0000000103102c6e -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x00000001020d2b60 -[NSArray makeObjectsPerformSelector:] + 256
7 UIKit 0x00000001031015f2 -[UINib instantiateWithOwner:options:] + 1867
8 UIKit 0x0000000102e950d1 -[UIViewController _loadViewFromNibNamed:bundle:] + 386
9 UIKit 0x0000000102e959f3 -[UIViewController loadView] + 177
10 UIKit 0x000000010311561c -[UITableViewController loadView] + 84
11 UIKit 0x0000000102e95d28 -[UIViewController loadViewIfRequired] + 201
12 UIKit 0x0000000102e9657c -[UIViewController view] + 27
13 TheGunnOracleApp 0x00000001014d50fb -[SWRevealViewController _deployForViewController:inView:] + 235
14 TheGunnOracleApp 0x00000001014d4f58 -[SWRevealViewController _deploymentForViewController:inView:appear:disappear:] + 136
15 TheGunnOracleApp 0x00000001014d48c1 -[SWRevealViewController _rearViewDeploymentForNewFrontViewPosition:] + 433
16 TheGunnOracleApp 0x00000001014d32f2 -[SWRevealViewController _setFrontViewPosition:withDuration:] + 82
17 TheGunnOracleApp 0x00000001014d26c6 __65-[SWRevealViewController _dispatchSetFrontViewPosition:animated:]_block_invoke + 70
18 TheGunnOracleApp 0x00000001014d1300 -[SWRevealViewController _enqueueBlock:] + 160
19 TheGunnOracleApp 0x00000001014d261b -[SWRevealViewController _dispatchSetFrontViewPosition:animated:] + 251
20 TheGunnOracleApp 0x00000001014d0154 -[SWRevealViewController setFrontViewPosition:animated:] + 148
21 TheGunnOracleApp 0x00000001014cffed -[SWRevealViewController revealToggleAnimated:] + 93
22 TheGunnOracleApp 0x00000001014d05df -[SWRevealViewController revealToggle:] + 63
23 UIKit 0x0000000102cf645c -[UIApplication sendAction:to:from:forEvent:] + 83
24 UIKit 0x0000000103137971 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 149
25 UIKit 0x0000000102cf645c -[UIApplication sendAction:to:from:forEvent:] + 83
26 UIKit 0x0000000102e7c344 -[UIControl sendAction:to:forEvent:] + 67
27 UIKit 0x0000000102e7c65d -[UIControl _sendActionsForEvents:withEvent:] + 444
28 UIKit 0x0000000102e7c7e7 -[UIControl _sendActionsForEvents:withEvent:] + 838
29 UIKit 0x0000000102e7b559 -[UIControl touchesEnded:withEvent:] + 668
30 UIKit 0x0000000102d63d5d -[UIWindow _sendTouchesForEvent:] + 2747
31 UIKit 0x0000000102d6544b -[UIWindow sendEvent:] + 4011
32 UIKit 0x0000000102d1254b -[UIApplication sendEvent:] + 371
33 UIKit 0x00000001034fda0f __dispatchPreprocessedEventFromEventQueue + 3248
34 UIKit 0x00000001034f6745 __handleEventQueue + 4879
35 CoreFoundation 0x00000001020d28e1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
36 CoreFoundation 0x00000001020b7b0c __CFRunLoopDoSources0 + 556
37 CoreFoundation 0x00000001020b6ff6 __CFRunLoopRun + 918
38 CoreFoundation 0x00000001020b6a04 CFRunLoopRunSpecific + 420
39 GraphicsServices 0x0000000107e37a6f GSEventRunModal + 161
40 UIKit 0x0000000102cf4808 UIApplicationMain + 159
41 TheGunnOracleApp 0x00000001014f2d0f main + 111
42 libdyld.dylib 0x0000000105ddd68d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

这是社交媒体中每个按钮的代码。

注意:由于 Facebook 一开始无法正常工作,我删除了其余社交媒体的代码:

import Foundation
import UIKit

class SocialMedia: UITableViewController{
@IBAction func facebookOpen(_ sender: Any) {
UIApplication.shared.open(NSURL(string: "https://www.facebook.com/gunnoracle")! as URL)
}
}

这是我的 Main.storyboard UITableViewController 的截图:

SocialMedia

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com