RHPreferences 1.0.0

RHPreferences 1.0.0

测试已测试
语言语言 Obj-CObjective C
许可证 BSD
发布最后发布2014年12月

Richard Heard维护。



  • Richard Heard

一个OS X窗口控制器,使您能够在应用程序中轻松提供具有多个标签的标准首选项窗口。

它还提供

  • 在不同大小的标签视图中自动调整大小(带动画)
  • 支持自定义NSToolbarItem
  • 保留最后一次使用的标签
  • 支持占位符NSToolbarItem(例如NSToolbarFlexibleSpaceItemIdentifier和NSToolbarShowFontsItemIdentifier)

Example Preferences Window.

RHPreferencesWindowController接口

@interface RHPreferencesWindowController : NSWindowController 

//init
-(id)initWithViewControllers:(NSArray*)controllers;
-(id)initWithViewControllers:(NSArray*)controllers andTitle:(NSString*)title;

//properties
@property (copy) NSString *windowTitle;
@property (assign) BOOL windowTitleShouldAutomaticlyUpdateToReflectSelectedViewController; //defaults to YES

@property (retain) IBOutlet NSToolbar *toolbar;
@property (retain) IBOutlet NSArray *viewControllers; //controllers should implement RHPreferencesViewControllerProtocol

@property (assign) NSUInteger selectedIndex;
@property (assign) NSViewController  *selectedViewController;

-(NSViewController *)viewControllerWithIdentifier:(NSString*)identifier;

//you can include these placeholder controllers amongst your array of view controllers to show their respective items in the toolbar
+(id)separatorPlaceholderController;        // NSToolbarSeparatorItemIdentifier
+(id)flexibleSpacePlaceholderController;    // NSToolbarFlexibleSpaceItemIdentifier
+(id)spacePlaceholderController;            // NSToolbarSpaceItemIdentifier

+(id)showColorsPlaceholderController;       // NSToolbarShowColorsItemIdentifier
+(id)showFontsPlaceholderController;        // NSToolbarShowFontsItemIdentifier
+(id)customizeToolbarPlaceholderController; // NSToolbarCustomizeToolbarItemIdentifier
+(id)printPlaceholderController;            // NSToolbarPrintItemIdentifier

@end

NSViewController首选项协议

// Implement this protocol on your view controller so that RHPreferencesWindow knows what to show in the tabbar. Label, image etc.
@protocol RHPreferencesViewControllerProtocol 
@required

@property (nonatomic, readonly, retain) NSString *identifier;
@property (nonatomic, readonly, retain) NSImage *toolbarItemImage;
@property (nonatomic, readonly, retain) NSString *toolbarItemLabel;

@optional

@property (nonatomic, readonly, retain) NSToolbarItem *toolbarItem; //optional, overrides the above 3 properties. allows for custom tabbar items.

//methods called when switching between tabs
-(void)viewWillAppear;
-(void)viewDidAppear;
-(void)viewWillDisappear;
-(void)viewDidDisappear;

-(NSView*)initialKeyView;   // keyboard focus view on tab switch...

@end

许可证

在修改的BSD许可证下发布。 (需要归属)

RHPreferences

Copyright (c) 2012 Richard Heard. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

版本支持

此框架代码在OS X 10.6 - 10.8上编译并经过测试