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를 처음 사용했습니다.