自定义单元格未重绘 Three20
我有一个尴尬的问题,调用 [self invalidateModel];
不会重绘我的自定义单元格。
我有一个带有操作表的 TTTableViewController,允许在按下时命令表格的显示。数据正确重绘,但单元格未重绘。反而有重用。
为了更好地说明:
在我的 CustomTableItemCell 类的 - (void)layoutSubviews {
中,我有这个:
if (bookmarked) {
UIImage *bookmark = [UIImage imageNamed: @"[email protected]"];
TTImageView *bookmarkView = [[TTImageView alloc] init];
bookmarkView.defaultImage = bookmark;
bookmarkView.frame = CGRectMake(297, 0, 16, 27);
[self.contentView addSubview:bookmarkView];
TT_RELEASE_SAFELY(bookmarkView);
}
基本上,如果我得到一个已添加书签的项目,我想在单元格的右侧显示一个功能区。此功能区可以正确显示。
当我使用操作表方法重新排序单元格并调用 invalidateModel 时,第一个没有任何功能区的单元格被放置在以前是功能区项目的位置,但没有重新绘制单元格,从而为没有功能区的项目提供功能区。
代码来源:
这是我的 TTTableViewController 的 createDatasource 函数:
- (void)createModel {
self.dataSource = [ServiceRequestDetailedDataSource viewDataSource:self.typeOfAction andOrderBy:orderBy];
// If dataSource nil, show an empty Message
if (self.dataSource == nil) {
[self showEmpty:YES];
}
}
这是我的 TTTableViewController 的操作表操作,它更改 orderBy 并调用无效模型:
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
self.orderBy = @"portfolio";
[self invalidateModel];
}
任何提示都很棒,我真的被困在这里了:'(
i have an awkward problem where calling to [self invalidateModel];
does not redraw my custom cells.
I have a TTTableViewController with an action sheet that allows to order the display of a table when pressed. The data gets redrawn correctly but the cells are not redrawn. Instead there are reused.
To illustrate better :
In my - (void)layoutSubviews {
of my CustomTableItemCell class i have this :
if (bookmarked) {
UIImage *bookmark = [UIImage imageNamed: @"[email protected]"];
TTImageView *bookmarkView = [[TTImageView alloc] init];
bookmarkView.defaultImage = bookmark;
bookmarkView.frame = CGRectMake(297, 0, 16, 27);
[self.contentView addSubview:bookmarkView];
TT_RELEASE_SAFELY(bookmarkView);
}
Basically if I get a bookmarked item, I want to display a ribbon on the right of my cell. This ribbon gets display correctly.
When I reorder my cell with the action sheet method and call invalidateModel, the first cell which didn't have any ribon gets putten at a place where was previously a ribbonned item but without redrawing the cell, thus giving a ribon to an item without ribbon.
Code source :
This is my createDatasource function of my TTTableViewController :
- (void)createModel {
self.dataSource = [ServiceRequestDetailedDataSource viewDataSource:self.typeOfAction andOrderBy:orderBy];
// If dataSource nil, show an empty Message
if (self.dataSource == nil) {
[self showEmpty:YES];
}
}
This is my action sheet action of my TTTableViewController that change the orderBy and calls invalidate model :
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
self.orderBy = @"portfolio";
[self invalidateModel];
}
Any tips would be great, I am really stuck here :'(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许[自我重新加载]会帮助您更新单元格视图。模型失效后调用
Maybe [self reload] would help you update cells view. Call it after model invalidation
找到了,就用reuseidentifier吧。我的不好。
Found it, just use reuseidentifier. My bad.