【问题标题】:Accessing the NSTableHeaderCell of a NSTableViewHeader for customization访问 NSTableViewHeader 的 NSTableHeaderCell 进行自定义
【发布时间】:2013-09-03 03:19:48
【问题描述】:

根据 NSTableHeaderView 类参考,NSTableHeaderView 使用 NSTableHeaderCell 类来实现其用户界面。

NSTableHeaderView 使用 NSTableHeaderCell 来实现它的用户界面。

NSTableHeaderView Class Reference

好的,现在我将我的 NSTableHeaderCell 子类化并进行了必要的更改,但是如何将我的自定义 NSTableHeaderCell 分配给 NSTableHeaderView?

【问题讨论】:

    标签: objective-c cocoa nstableview nstableviewcell nstableheaderview


    【解决方案1】:
        Try like this:-
    
        #import <Cocoa/Cocoa.h>
    
        @interface customHeaderCell : NSTableHeaderCell
        {
    
        }
    
        @end
    
        #import "customHeaderCell.h"
    
        @implementation customHeaderCell
    
        -(id)initTextCell:(NSString *)aString
        {
       if([aString isEqualToString:@"yourHeaderCell"])
    {
        // do your stuff here;
    }
            return [super initTextCell:aString];
        }
    
        @end
    
    
        Now in other class wherever your table view you are using write the following the code:-
    
        -(IBAction)addData:(id)sender
        {
            for (NSTableColumn *col in [tableView tableColumns])
            {
                customHeader=[[customHeaderCell alloc]initTextCell:[col identifier]];
    
            }
    
        }
    

    【讨论】:

    • 你能解释一下吗?我是 cocoa dev 的新手,我没有得到“现在在其他类中,无论您使用的是什么表视图,请编写以下代码:-”我的意思是这个 addData 是什么。我不明白 customeHeaderCell 是如何与我的 NSTableHeaderView 子类相关联的?我仍然不知道如何链接这两个子类
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-03
    • 2012-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-02
    相关资源
    最近更新 更多