相关疑难解决方法(0)

swift:如何在单元格中的按钮被点击时获取indexpath.row?

我有一个带有按钮的tableview,我想在使用其中一个时使用indexpath.row.这是我现在拥有的,但总是0

var point = Int()
func buttonPressed(sender: AnyObject) {
    let pointInTable: CGPoint =         sender.convertPoint(sender.bounds.origin, toView: self.tableView)
    let cellIndexPath = self.tableView.indexPathForRowAtPoint(pointInTable)
    println(cellIndexPath)
    point = cellIndexPath!.row
    println(point)
}
Run Code Online (Sandbox Code Playgroud)

button touch nsindexpath swift

87
推荐指数
7
解决办法
10万
查看次数

[UITapGestureRecognizer标签]:发送到实例的无法识别的选择器

我正在进行一系列的imageview安排,并TapView为其分配一个识别器

UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc]
                                         initWithTarget:self action:@selector(action:)];
[tapRecognizer setNumberOfTouchesRequired:1];
[tapRecognizer setDelegate:self];
imageView.userInteractionEnabled = YES;
[imageView addGestureRecognizer:tapRecognizer];
Run Code Online (Sandbox Code Playgroud)

我已将选择器定义为:

-(void) action:(id)sender
  {
    NSLog(@"TESTING TAP");
    NSLog (@"%d",[sender tag]);
  }
Run Code Online (Sandbox Code Playgroud)

这是崩溃,我收到错误消息: -

[UITapGestureRecognizer tag]: unrecognized selector sent to instance 0x145d0210

objective-c ios4 xcode4.5

11
推荐指数
4
解决办法
1万
查看次数

标签 统计

button ×1

ios4 ×1

nsindexpath ×1

objective-c ×1

swift ×1

touch ×1

xcode4.5 ×1