简体   繁体   中英

Outlets found nil after moving tableviewcell to new view controller

I originally had several UITableViewCell s on a UIViewController with a UITableView . Then, I moved the UITableViewCell s to a new UITableViewController I created because I wanted to make them static cells and the only way to make them static was to use them on a UITableViewController . However, after I moved, them, although everything was connected and all the cells were set to the right xib files, the app crashed and it said the outlets on the UITableViewCell s, like my UILabel s, were found nil. I then tried to create brand new UITableViewCell s with brand new xib files on the UITableViewController , but then I couldn't even connect any outlets for any UILabel s or anything else. Does anyone know how to troubleshoot this? All my code looks normal and I've been using UITableView s for a long time, just never creating static cells before.

I figured it out! In a UITableViewController with Static Cells you don't need to create a custom class for the cells and drag your outlets there (what I did); you can just drag your outlets directly onto the UITableViewController and it will work there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM