[英]Cocoa PDFView does not resize
我试图在XCode中创建PDFView
类的自定义子类。 我在InterfaceBuiler中向我的窗口添加了一个PDFView
实例,并为子类创建以下文件:
MyPDFView.h:
#import <Quartz/Quartz.h>
@interface MyPDFView : PDFView
-(void)awakeFromNib;
-(void)mouseDown:(NSEvent *)theEvent;
@end
MyPDFView.m:
#import "MyPDFView.h"
@implementation MyPDFView
-(void)awakeFromNib
{
[self setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable|NSViewMinXMargin|NSViewMaxXMargin|NSViewMinYMargin|NSViewMaxYMargin];
[self setAutoScales:YES];
}
- (void)mouseDown:(NSEvent *)theEvent
{
unsigned long mask = [self autoresizingMask];
NSLog(@"self autoresizingMask: %lu",mask);
NSLog(@"NSViewHeightSizable: %lu",mask & NSViewHeightSizable);
NSLog(@"NSViewWidthSizable: %lu",mask & NSViewWidthSizable);
NSLog(@"self setAutoScales: %@",[self autoScales] ? @"YES" : @"NO");
NSView* sv = [self superview];
NSLog(@"superview autoresizesSubviews: %@",[sv autoresizesSubviews] ? @"YES" : @"NO");
NSSize frame_dims = [self frame].size;
NSLog(@"Frame: (%f,%f)",frame_dims.width,frame_dims.height);
NSSize bounds_dims = [self bounds].size;
NSLog(@"Bounds: (%f,%f)",bounds_dims.width,bounds_dims.height);
NSSize sv_frame_dims = [sv frame].size;
NSLog(@"Superview Frame: (%f,%f)",sv_frame_dims.width,sv_frame_dims.height);
NSSize sv_bounds_dims = [sv bounds].size;
NSLog(@"Superview Bounds: (%f,%f)",sv_bounds_dims.width,sv_bounds_dims.height);
[super mouseDown:theEvent];
}
@end
但是,尽管设置了所有内容并且单击PDFView
区域时触发的后续NSLog
语句确认对象应该调整大小,但调整窗口大小不会调整PDFView
大小。 任何人都可以解释我需要做些什么来使PDFView
区域与父窗口的大小PDFView
缩放?
这个项目的完整代码将允许您构建和运行它在这里:
我了解您的要求是在调整父窗口大小时调整PDFView
大小。 有两种方法可以实现这一目标
[self setFrame:[self superview].bounds];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.