sha*_*awg 6 uitableview ios swift
我怎样才能调用的函数ViewController,从一个自定义的tableview细胞UITableView在ViewController(使用SWIFT)?
Adn*_*tab 10
你可以用很少的方法做到这一点
UITabelVeiwCell然后从单元调用self.delegate.whatEverDeelgate()NSNotificationCenter.defaultCenter().addObserver(self, selector: "nameOfSelector", name: "Name Of Notification", object: nil),然后从tableView单元格postNotification注册,但请确保您还要删除Observer,请访问此链接以获取更多详细信息@weak var viewController:YourViewcontroller并使用它来调用视图控制器上的方法(不推荐)从您的手机发布通知:
NSNotificationCenter.defaultCenter().postNotificationName("notificationName", object: nil)
Run Code Online (Sandbox Code Playgroud)
然后在你的 viewController 中监听它:
NSNotificationCenter.defaultCenter().addObserver(self, selector: "functionToCall", name: "notificationName", object: nil)
Run Code Online (Sandbox Code Playgroud)
确保在 viewController 中定义新函数:
func functionToCall() {
//This function will be called when you post the notification
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6670 次 |
| 最近记录: |