initwithstyle:reuseIdentifier:未调用 [英] initwithstyle:reuseIdentifier: not called

查看:646
本文介绍了initwithstyle:reuseIdentifier:未调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建自己的自定义 UITableViewCell ,以用作原型单元格的后端。在我的类中,我重写了 initwithstyle:reuseIdentifier:方法来进行一些自定义初始化,但我的初始化程序没有被调用。我在其内部的第一行有一个断点,以及 dequeueResusableCellWithIdentifier:上的断点。调用 dequeueResusableCellWithIdentifier:方法,它返回一个已启动的单元格,但 initwithstyle:reuseIdentifier:中的断点是还没到。任何帮助都会很棒。

I'm creating my own custom UITableViewCell to use as the backend of a prototype cell. In my class I override the initwithstyle:reuseIdentifier: method to do some custom initialization, but my initializer is not called. I have a break point on the first line inside of it, as well as a break point on dequeueResusableCellWithIdentifier:. The dequeueResusableCellWithIdentifier: method is called, and it returns a initilized cell, but the break point in initwithstyle:reuseIdentifier: is not reached. Any help would be great.

推荐答案

如果您的单元格是从故事板原型(您已声明为自定义类)创建的在IB)然后它将不会与 initWithStyle ... 创建,但 initWithCoder:而不是像任何其他对象一样从笔尖加载。如果你有任何设置代码,它应该在那里或 awakeFromNib

If your cell is being created from a storyboard prototype (which you have declared as the custom class in IB) then it won't be created with initWithStyle... but initWithCoder: instead, like any other object loaded from a nib. If you have any setup code, it should be in there or in awakeFromNib.

这篇关于initwithstyle:reuseIdentifier:未调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆