У меня есть два UILabels
с двумя UITapGestureRecognizers
в UITableViewCell
.Как узнать идентификатор отправителя в Swift
cell.Username.tag = indexPath.row
cell.SharedUser.tag = indexPath.row
let tapGestureRecognizer2 = UITapGestureRecognizer(target:self, action:"GoToProfil:")
let tapGestureRecognizer3 = UITapGestureRecognizer(target:self, action:"GoToProfil:")
cell.Username.userInteractionEnabled = true
cell.Username.addGestureRecognizer(tapGestureRecognizer2)
cell.SharedUser.userInteractionEnabled = true
cell.SharedUser.addGestureRecognizer(tapGestureRecognizer3)
func GoToProfil (sender: AnyObject!) {
self.performSegueWithIdentifier("GoToProfilSegue", sender: sender)
}
Я использую Segue
нажать другую UIViewController
, и я переопределение функции PrepareSegue
, чтобы отправить необходимую информацию, соответствующую Sender
тега.
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
let ProfilView = segue.destinationViewController as! Profil
ProfilView.hidesBottomBarWhenPushed = true
ProfilView.title = posts[sender.view!.tag].User?.objectForKey("Name") as? String
ProfilView.User = posts[sender.view!.tag].User
}
Моя проблема заключается в том, что я хочу знать, какая UILabel
была нажата, зная, что я уже использую tag
.
Что такое 'UITextLabel'? Нет такого понятия. – rmaddy
Извините, я отредактировал сообщение, я имел в виду UILabel –
Вы можете добавить другую функцию, которая будет вызываться, когда второй UILabel будет прослушиваться. Затем эта функция вызовет другой идентификатор seg, такой как 'performSegeueWithIdentifier (« GoToProfilSeg2 »)'. Затем в вашем методе 'prepareForSegue' вы просто используете оператор' if', чтобы обрабатывать, какой segue нужно перенести, то есть 'if segue.identifier ==" ... "" {...} ' – MikeG