में प्रतिनिधिमंडल ने 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
अब कार्यान्वयन:
इस कोड का उपयोग करें और हर किसी को है कि यह में व्यवहार्य मिलेगा के लिए संशोधित करने के लिए नि: शुल्क है उनकी परियोजना :)।
मैं स्टैक ओवरफ्लो में नया हूं (भले ही मैं बिना किसी खाते के कुछ महीनों तक छिप गया हूं) इसलिए प्रत्येक आलोचना का गर्मजोशी से स्वागत है।