我做了大量的研究UISplitView
,并无法找到一种方法来控制分割视图时,主和细节有一个视图发生变化。UISplitViewController委托在一个单身人士
然后我找到了一种方法来管理它是一个代表单例类的代理。
我的问题是,我不知道如果这是正确的路要走。我很关心reusability
和memory managment
。此外,我有一种感觉,它违反了苹果的指导方针,以单身代表。
这是我(和它的实际工作):
// SharedSplitViewDelegate.h
/* In the detail view controllers:
// in the initial detail view controller
- (void)awakeFromNib
{
[super awakeFromNib];
// needs to be here, otherwise if it's booted in portrait the button is not set
self.splitViewController.delegate = [SharedSplitViewDelegate initSharedSplitViewDelegate];
}
// shared between all detail view controllers
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
SharedSplitViewDelegate *rotationHandler = [SharedSplitViewDelegate initSharedSplitViewDelegate];
[self.toolbar setItems:[rotationHandler processButtonArray:self.toolbar.items] animated:YES];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
*/
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface SharedSplitViewDelegate : NSObject <UISplitViewControllerDelegate>
+ (id)initSharedSplitViewDelegate; // returns the singleton class instance
- (NSArray *)processButtonArray:(NSArray *)array; // Adds and removes the button from the toolbar array. Returns the modified array.
@end
现在执行:
这段代码是免费使用和修改大家会觉得可行的他们的项目:)。
我是StackOverflow的新手(尽管我已经潜伏了几个月没有帐户),所以每个评论都受到热烈的欢迎。