UITable 位于滚动视图上,UITable 不响应 reloadData 调用
我有一个滚动视图,上面有 2 个 UITable。 桌子上的一切都运转良好。两个表都不需要自行滚动。 如果我调用
[self.tableOne reloadData];当按下按钮时它就会起作用。但是当我在 UITextView 的委托方法中调用它时,它不会起作用。这是一些线程问题吗?或者是什么导致了这种奇怪的行为。
当用户按下每个单元格中的 UITextView 时,我想增加 TableCell 的大小。
我在这里添加了一个 NSLog 来确认该方法正在被调用。
- (void)textViewDidBeginEditing:(UITextView *)textView
{
theTableCellCurrentlyBeingEdited = textView.tag;
[self.tableOne reloadData];
}
受到触动,我注意到哪个单元格处于活动状态,并调用重新加载表,以便我可以调整该单元格的高度,
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath: (NSIndexPath *) indexPath
{
if (theTableCellCurrentlyBeingEdited == indexPath.row)
{
return 120;
}
else
{
return TABLE_CELL_HEIGHT;
}
}
但 heightForRowAtIndex 永远不会被调用。
我将 tableOnes 数据源和委托设置为 self。 在我的 .h 中,我添加了
<UITextViewDelegate, UITableViewDelegate, UITableViewDataSource>
所以电话到达这里。
有人能给我一些关于出了什么问题的建议吗?
非常感谢, -代码
I've got a scroll view, with 2 UITables on it.
Everything about the table work well. Neither of the tables need to scroll themselves.
If I call
[self.tableOne reloadData]; when a button is pressed it works. But when I call it in a delegate method of UITextView it does not action. Is this some threading issue? Or what is causing this bizarre behavior.
I want to increase the size of a TableCell when the user presses on UITextView thats in each cell.
I added a NSLog here to confirm that this method is getting called.
- (void)textViewDidBeginEditing:(UITextView *)textView
{
theTableCellCurrentlyBeingEdited = textView.tag;
[self.tableOne reloadData];
}
Gets touched I note which cell is active, and call reload table so I can adjust the height of this cell in
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath: (NSIndexPath *) indexPath
{
if (theTableCellCurrentlyBeingEdited == indexPath.row)
{
return 120;
}
else
{
return TABLE_CELL_HEIGHT;
}
}
But heightForRowAtIndex never gets called.
I have tableOnes datasource and delegate set to self.
In my .h I have added
<UITextViewDelegate, UITableViewDelegate, UITableViewDataSource>
So the calls are getting here.
Anybody able to give me some advice as to what is going wrong?
Many Thanks,
-Code
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先。你在哪里调用textView的文本?
您正在使用
theTableCellCurrentlyBeingEdited = textView.tag;
并且标签不会为您提供您输入的文本。您只是更改单元格的标签,这不会改变单元格的视觉效果。
第二。为什么不调用:
或
以便在第一个委托方法中,您的单元格会更新您编写的每个字符,而在第二个委托方法中,您确定用户已完成在文本视图中的写入?
First of all. Where do you call the text of the textView?
You are using
theTableCellCurrentlyBeingEdited = textView.tag;
And the tag will not give you the text you entered. You are just changing the tag of your cell which won't change a thing to the visuals of the cell.
Second. Why not call:
or
So that in the first delegate method your cell gets updated every char you write and in the second you are sure the user is done writing in the textview?