3 回答

TA貢獻1993條經驗 獲得超6個贊
tag
tableView:cellForRowAtIndexPath:
superview
UISwitch
UITableViewCell
UITableView
static NSIndexPath *indexPathForView(UIView *view) { while (view && ![view isKindOfClass:[UITableViewCell class]]) view = view.superview; if (!view) return nil; UITableViewCell *cell = (UITableViewCell *)view; while (view && ![view isKindOfClass:[UITableView class]]) view = view.superview; if (!view) return nil; UITableView *tableView = (UITableView *)view; return [tableView indexPathForCell:cell];}
tableView:cellForRowAtIndexPath:
.

TA貢獻1812條經驗 獲得超5個贊
tag
extension Int { public init(indexPath: IndexPath) { var marshalledInt: UInt32 = 0xffffffff let rowPiece = UInt16(indexPath.row) let sectionPiece = UInt16(indexPath.section) marshalledInt = marshalledInt & (UInt32(rowPiece) << 16) marshalledInt = marshalledInt + UInt32(sectionPiece) self.init(bitPattern: UInt(marshalledInt)) } var indexPathRepresentation: IndexPath { let section = self & 0x0000ffff let pattern: UInt32 = 0xffff0000 let row = (UInt32(self) & pattern) >> 16 return IndexPath(row: Int(row), section: Int(section)) }}
tableView(_:, cellForRowAt:)
cell.yourSwitch.tag = Int(indexPath: indexPath)
func didToogle(sender: UISwitch){ print(sender.tag.indexPathRepresentation)}
{section area length}{all remaining}[4 BITS: section area length - 1]
- 3 回答
- 0 關注
- 516 瀏覽
添加回答
舉報