Swift 'text' is unavailable: APIs deprecated as of iOS7. textLabel does not work

痞子三分冷 提交于 2019-12-20 07:28:38

问题


I keep having this error

I've seen other questions been answered by using textLabel.text, but it doesn't work in my case

I'm new to swift so could someone please explain me why and how to solve this.


回答1:


You need to unwrap textLabel by using an ! after textLabel.

This is because textLabel is an Optional (hence the textLabel? type instead of just textLabel). Read more about optionals here.

Hope that helps!



来源:https://stackoverflow.com/questions/26330869/swift-text-is-unavailable-apis-deprecated-as-of-ios7-textlabel-does-not-work

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!