2011-05-02 53 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?