cellForRowAtIndexPath将返回nil.
解决方法 根据 Apple Documentation关于cellForRowAtIndexPath:,它返回“表示表格的单元格的对象,如果单元格不可见或者indexPath超出范围,则返回nil”.根据MVC Pattern,UItableVIEwCell是一个视图.所以我更喜欢维护一个模型对象 – 也许它就像Nsstring实例一样简单 – 如果我是你的话,将文本保存在单元格中.您可以通过向控制器添加UITextFIEldTextDIDChangeNotification键的观察者来观察UITextFIEld的更改.
- (voID)textFIEldDIDChangeText:(NSNotification *)notification{ // Assume your controller has a Nsstring (copy) property named "text". self.text = [(UITextFIEld *)[notification object] text]; // The notification's object property will return the UITextFIEld instance who has posted the notification.}- (UItableVIEwCell *)tableVIEw:(UItableVIEw *)tableVIEw cellForRowAtIndexPath:(NSIndexPath *)indexPath{ // Dequeue cell... // ... if (!cell) { // Init cell... // ... [[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(textFIEldDIDChangeText:) name:UITextFIEldTextDIDChangeNotification object:yourTextFIEld]; } // Other code... // ... return cell;}
不要忘记删除-dealloc中的观察者.
总结以上是内存溢出为你收集整理的ios – UITableViewCell将消失全部内容,希望文章能够帮你解决ios – UITableViewCell将消失所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)