dequeueReusableCellWithIdentifier always return non nil?

痞子三分冷 提交于 2019-12-01 00:11:34

If you're using storyboard and set the UITableViewCell's Identifier to the identifier to the one you are using in dequeueReusableCellWithIdentifier ("AlbumCell" in your case) in the storyboard file, the UITableView will always create cells for you. I guess this is a feature of storyboard. If the identifier can't be found in your storyboard, then you need to create cells manually.

I know it is possible for the return of the cell to be nil and you should check for it. Usually this will not be the case as you should get a cell created for you from your identifier you supplied. If you for instance did not have the identifier correct and the pool was empty I believe that is the case where you would get nil and you could do an aloc init to create a new cell. Also I should add the prototype cell you create in xcode is what creates the cell and that is why it should start as non nil and you don't have to create one.

To better answer this go to iTunes and go to the course iPad and iPhone Application Development - Paul Hegarty - Stanford CS193p course. Go to lecture (25) 9. Table Views go to 26 minutes in.

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