列表单元格尾部可以添加各种样式的附件,如感叹号,三角箭头等。而且点击内容区域与点击附件的这两个响应事件是不同的,这样可以方便我们实现不同的功能(比如点击内容则查看详情,点击感叹号则编辑)
![](https://i-blog.csdnimg.cn/blog_migrate/d4ffa6df2c7000dac22ed7848f555c67.png)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
//列表项尾部附件点击
override
func
tableView(tableView:
UITableView
,
accessoryButtonTappedForRowWithIndexPath indexPath:
NSIndexPath
) {
self
.tableView!.deselectRowAtIndexPath(indexPath, animated:
true
)
var
itemString =
self
.tasks[indexPath.row]
var
alertview =
UIAlertView
();
alertview.title =
"尾部感叹号点击!"
alertview.message =
"你选中了【\(itemString)】"
;
alertview.addButtonWithTitle(
"确定"
)
alertview.show();
}
//列表项内容点击
override
func
tableView(tableView:
UITableView
, didSelectRowAtIndexPath indexPath:
NSIndexPath
) {
self
.tableView!.deselectRowAtIndexPath(indexPath, animated:
true
)
var
itemString =
self
.tasks[indexPath.row]
var
alertview =
UIAlertView
();
alertview.title =
"列表项内容点击!"
alertview.message =
"你选中了【\(itemString)】"
;
alertview.addButtonWithTitle(
"确定"
)
alertview.show();
}
|