【发布时间】:2017-01-25 12:07:01
【问题描述】:
我正在尝试开发一款外观与我附在此处的图片相似的应用,因为我真的很喜欢这个创意。
选择一个项目后,它会下拉并开始播放剪辑
关于如何实现这一点的任何想法?我可以使用表格和列表,但我不知道如何实际实现这样的东西。
【问题讨论】:
我正在尝试开发一款外观与我附在此处的图片相似的应用,因为我真的很喜欢这个创意。
选择一个项目后,它会下拉并开始播放剪辑
关于如何实现这一点的任何想法?我可以使用表格和列表,但我不知道如何实际实现这样的东西。
【问题讨论】:
您可以通过多种方式实现这一目标
让 indexPath = NSIndexPath(forRow: YourSelectedRow, inSection: 0)
tableView.insertRowsAtIndexPaths(indexPath, withRowAnimation: .none )
insert a different row here which will be tricky to manage.
创建所有这些标题,并在所选部分下仅创建一个单元格。
var selectedSection = -1
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
{
let view = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 50)
let button = UIButton(frame: view.frame)
button.tag = section
button.addTarget(self, action: #selector(selectExercise(_:), forControlEvents: UIControlEvents.TouchUpInside)
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int
{
return 5
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
if section == selectedSection
{
return 1
}
else
{
return 0
}
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCellWithIdentifier(“YourDetailCell”, forIndexPath: indexPath) as! YourDetailCell
return cell
}
fun selectExercise(sender:UIButton)
{
selectedSection = sender.tag
}
创建两个单元格并使用动画更改具有整个单元格部分的特定单元格
var selectedRow = -1
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
{
if selectedRow == -1
{
selectedRow = indexPath.row
tblConfirmedServices.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .Bottom)
}
else
{
selectedRow = - 1
tblConfirmedServices.reloadRowsAtIndexPaths([indexPathPre], withRowAnimation: .Top)
}
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
if selectedRow = indexPath.row
{
let cell = tableView.dequeueReusableCellWithIdentifier(“YourDetailCell”, forIndexPath: indexPath) as! YourDetailCell
return cell
}
else
{
let cell = tableView.dequeueReusableCellWithIdentifier(“YourCell”, forIndexPath: indexPath) as! YourCell
return cell
}
}
【讨论】: