我一直在尝试按照youtube上的指南在我的tableview单元格中创建一个分享按钮但是我收到的错误对我来说毫无意义 "无法转换类型的值(VideoViewController) - > (UIButton) - >()到期望参数"字符串" 在这行代码中:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:id="@+id/qrcodelayout">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/qrimageView"
android:layout_gravity="center_horizontal"
android:layout_marginTop="8dp" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/qrcodetext"
android:gravity="center"
android:layout_gravity="center_horizontal"
android:layout_marginTop="4dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</RelativeLayout>
继承我的按钮代码
cell.shareButton.addTarget(self, action: Selector(VideoViewController.shareAction(_:)), forControlEvents: .TouchUpInside)
答案 0 :(得分:2)
尝试这样,它应该工作
cell.shareButton.addTarget(self, action: #selector(VideoViewController.shareAction(_:)) , forControlEvents: .TouchUpInside)