所以我试图创建一个在tableview单元格中单击视图时出现的弹出窗口。这是我到目前为止所尝试的内容。 这就是我在customcell中的内容:
__global__ void compact_kernel(unsigned int* const d_inputVals,
unsigned int* const d_inputPos,
unsigned int* const d_outputVals,
unsigned int* const d_outputPos,
const size_t numElems,
const size_t refBit)
{
const size_t tid = blockIdx.x * blockDim.x + threadIdx.x;
// predicate
const bool predicate = (d_inputVals[tid] & 1) == refBit;
extern __shared__ int s[];
}
void your_sort(unsigned int* const d_inputVals,
unsigned int* const d_inputPos,
unsigned int* const d_outputVals,
unsigned int* const d_outputPos,
const size_t numElems)
{
const size_t numBlocks = numElems/512;
const size_t numThreadsPerBlock = 256;
compact_kernel<<<numBlocks, numThreadsPerBlock, sizeof(int)*numElems>>>(d_inputVals, d_inputPos, d_outputVals, d_outputPos, numElems, 0);
compact_kernel<<<numBlocks, numThreadsPerBlock, sizeof(int)*numElems>>>(d_inputVals, d_inputPos, &d_outputVals[numElems/2], &d_outputPos[numElems/2], numElems, 1);
这就是我在视图控制器中的内容:
class Cell: UITableViewCell {
@IBOutlet weak var openingHoursView: CustomView!
override func awakeFromNib() {
super.awakeFromNib()
let tap = UITapGestureRecognizer(target: self, action: Selector("openingHoursTap:"))
openingHoursView.addGestureRecognizer(tap)
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
}
标识符是正确的。锚点是segue的tableview。我以前从未真正创建过一个可点击的视图,但是只用一个按钮做了同样的事情并且工作正常。没有错误,应用只是在点击视图时崩溃。
我猜测它可能与我无关,而不是将其添加到单个单元格的cellForRowAtIndexPath中。如果我不能添加目标,那么如何通过视图完成?
答案 0 :(得分:0)
您在表格视图单元格中调用openingHoursTap:
但实际的实现位于视图控制器中。这就是崩溃的原因。因此,正确的方法是在视图控制器的tableView: cellForRowAtIndexpath:
中添加点击手势识别器。
示例:
func tableView(_ tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell")
let tap = UITapGestureRecognizer(target: self, action:Selector("openingHoursTap:"))
cell.openingHoursView.addGestureRecognizer(tap)
}