2011-05-02 54 views
0

我仍然在用Obj-c学习曲线。 我试图重写TTThumbsTableViewCell从Three20, setColumnCount方法,但我不知道为什么它不会工作。 在超类(TTThumbsTableViewCell)中的方法setColumnCount我添加了一个NSLog(@“测试超级”)和TTThumbsTableViewCell的子类在setColumnCount方法我已经添加NSLog(@“测试Sub”)和子类方法从不打印出“测试小组”。覆盖Obj-c不工作的方法

我不确定如果我在Obj-C中正确覆盖,基本上我将TTThumbsTableViewCell中的整个方法setColumnCount复制到子类并在那里修改它,但它仍然不会在子类中运行重写的方法。

有什么我失踪了吗? 林与XCode的工作4

在此先感谢

布雷特

南非

+0

如果没有看到代码就不能告诉任何东西... – 2011-05-02 17:12:23

+0

嗨乔恩里德,感谢您的答复,对不起,没有代码的职位。很快就会回复。 – BrettStuart 2011-05-02 17:42:24

回答

0

我有一个TTThumbsTableViewCell子类,称为GridImage

@interface GridImage:TTThumbsTableViewCell '<' TTPhoto> {

//Code... 

@end

的.M覆盖是该setColumnCount方法

'#' 进口 “GridImage.h”

@implementation GridImage

  • (无效)setColumnCount:(NSInteger的) columnCount NSLog(@“测试小组”); if(_columnCount!= columnCount){(TTThumbView * thumbView in _thumbViews){ [thumbView removeFromSuperview]; } [_thumbViews removeAllObjects];

    _columnCount = columnCount; 
    
    for (NSInteger i = _thumbViews.count; i < _columnCount; ++i) { 
        TTThumbView* thumbView = [[[TTThumbView alloc] init] autorelease]; 
        [thumbView addTarget:self action:@selector(thumbTouched:) 
         forControlEvents:UIControlEventTouchUpInside]; 
        [self.contentView addSubview:thumbView]; 
        [_thumbViews addObject:thumbView]; 
        if (_photo) { 
         [self assignPhotoAtIndex:_photo.index+i toView:thumbView]; 
        } 
    } 
    

    }}

难道是什么做的 '<' TTPhoto>协议从Three20?