コントロールのサイズを動的に調整し、コントロールの表示を非表示にする方法
1269 ワード
//
// AppDelegate.h
//
#import <Cocoa/Cocoa.h>
@interface AppDelegate : NSObject <NSApplicationDelegate,NSTextViewDelegate>
{
NSTextView *_textView;
NSButton *_button;
NSTextField *_textField;
NSTableView * _tableview;
}
@property IBOutlet NSTextView *textView;
@property IBOutlet NSButton *button;
@property IBOutlet NSTextField *textField;
@property IBOutlet NSTableView *tableView;
@property (assign) IBOutlet NSWindow *window;
- (IBAction)dosome:(id)sender;
@end
//
// AppDelegate.m
#import "AppDelegate.h"
@implementation AppDelegate
@synthesize button = _button;
@synthesize textField = _textField;
@synthesize textView = _textView;
@synthesize tableView = _tableview;
- (IBAction)dosome:(id)sender
{
NSLog(@" you click btn");
[self.button setHidden:YES];//
NSSize size = {200,100};
[[self.textView enclosingScrollView] setFrameSize:size];// textview 、
[[self.tableView enclosingScrollView] setFrameSize:size];// tableview 、
}
- (void) awakeFromNib
{
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
}
@end
注:XLBファイルでは.hの最初のIBOutletは接続を推奨します.そうしないと、変更時に変化はありません.に感銘を与える