मैं ऐसे ऐप पर काम कर रहा हूं जहां बाईं ओर "दराज" होना बहुत फायदेमंद होगा। मैं यह देखने के लिए कुछ प्रारंभिक परीक्षण कर रहा हूं कि मैं इसे कैसे पूरा करूँगा, और मुझे कुछ बहुत ही बुनियादी समस्याएं आ रही हैं।आईओएस: स्लाइडिंग UIView ऑन/ऑफ स्क्रीन
मेरे सेटअप
1. मैं Xcode 4.
2 में एक एकल दृश्य आवेदन टेम्पलेट का उपयोग कर रहा xib की 'मुख्य/सीमा "दृश्य के लिए, मैं 2 UIViews (LeftPanel और RightPanel) जोड़ दिया है और एक यूआईबटन (शोहाइडबटन)।
3. मैंने आसानी से दृश्यता के लिए वामपंथी हरा और राइटपैनल नीला रंग दिया है।
4. जब दृश्य लोड होता है, तो दोनों पैनल दिखाई दे रहे हैं और UIButton में "छुपाएं पैनल" टेक्स्ट है।
5. बटन दबाए जाने पर, वामपैनल को स्क्रीन (बायीं तरफ) स्लाइड करना चाहिए और राइटपैनल को अपनी मूल जगह और बाएं पैनेल द्वारा खाली स्थान लेने के लिए विस्तार करना चाहिए।
6. इस बिंदु पर, शोहाइड बटन को अपना टेक्स्ट "पैनल दिखाएं" में बदलना चाहिए।
7. बटन को फिर से दबाए जाने पर, वामपैनल को स्क्रीन पर (बाईं तरफ से) स्लाइड करना चाहिए और राइटपैनल को अपनी मूल जगह "इसे वापस देने" के लिए छोटा होना चाहिए।
8. इस बिंदु पर, शोहाइडबटन को अपना टेक्स्ट वापस "छुपाएं पैनल" में बदलना चाहिए।
मैं animateWithDuration:animations:completion:
का उपयोग कर एनीमेशन को कार्यान्वित कर रहा हूं। अब तक, संक्रमण OFF स्क्रीन ठीक काम कर रही है (वास्तव में, वास्तव में)।
मुझे परेशान करने वाला यह है कि जब मैं वामपैनेल को "वापस" लाने की कोशिश करता हूं, तो मुझे EXC_BAD_ACCESS मिल रहा है। मैंने नीचे अपना कोड पोस्ट कर दिया है, और मैंने इसे देखा है, लेकिन मैं वास्तव में नहीं देख सकता कि मैं जो रिलीज़ कर रहा हूं उसे रिलीज़ किया जा रहा है (या जो भी EXC_BAD_ACCESS उत्पन्न कर रहा है)।
DrawerTestingViewController.h
#import <UIKit/UIKit.h>
typedef enum {
kHidden,
kShown
} PanelState;
@interface DrawerTestingViewController : UIViewController {
PanelState currentState;
UIButton *showHideButton;
UIView *leftPanel;
UIView *rightPanel;
}
@property (assign, nonatomic) PanelState CurrentState;
@property (strong, nonatomic) IBOutlet UIButton *ShowHideButton;
@property (strong, nonatomic) IBOutlet UIView *LeftPanel;
@property (strong, nonatomic) IBOutlet UIView *RightPanel;
- (IBAction)showHidePressed:(id)sender;
@end
DrawerTestingViewController.m
#import "DrawerTestingViewController.h"
@implementation DrawerTestingViewController
@synthesize CurrentState = currentState;
@synthesize LeftPanel = leftPanel;
@synthesize RightPanel = rightPanel;
@synthesize ShowHideButton = showHideButton;
#pragma mark - My Methods
- (IBAction)showHidePressed:(id)sender
{
switch ([self CurrentState]) {
case kShown:
// Hide the panel and change the button's text
// 1. Hide the panel
[UIView animateWithDuration:0.5
animations:^{
// b. Move left panel from (0, 0, w, h) to (-w, 0, w, h)
CGRect currLeftPanelRect = [[self LeftPanel] frame];
currLeftPanelRect.origin.x = -1 * currLeftPanelRect.size.width;
[[self LeftPanel] setFrame:currLeftPanelRect];
// c. Expand right panel from (x, 0, w, h) to (0, 0, w + x, h)
CGRect currRightPanelRect = [[self RightPanel] frame];
currRightPanelRect.origin.x = 0;
currRightPanelRect.size.width += currLeftPanelRect.size.width;
[[self RightPanel] setFrame:currRightPanelRect];}
completion:NULL];
// 2. Change the button's text
[[self ShowHideButton] setTitle:@"Show Panel" forState:UIControlStateNormal];
// 3. Flip [self CurrentState]
[self setCurrentState:kHidden];
break;
case kHidden:
// Show the panel and change the button's text
// 1. Show the panel
[UIView animateWithDuration:0.5
animations:^{
// b. Move left panel from (-w, 0, w, h) to (0, 0, w, h)
CGRect currLeftPanelRect = [[self LeftPanel] frame];
currLeftPanelRect.origin.x = 0;
[[self LeftPanel] setFrame:currLeftPanelRect];
// c. Expand right panel from (0, 0, w, h) to (leftWidth, 0, w - leftWidth, h)
CGRect currRightPanelRect = [[self RightPanel] frame];
currRightPanelRect.origin.x = currLeftPanelRect.size.width;
currRightPanelRect.size.width -= currLeftPanelRect.size.width;
[[self RightPanel] setFrame:currRightPanelRect];}
completion:NULL];
// 2. Change the button's text
[[self ShowHideButton] setTitle:@"Hide Panel" forState:UIControlStateNormal];
// 3. Flip [self CurrentState]
[self setCurrentState:kShown];
break;
default:
break;
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self setCurrentState:kShown];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
switch ([self CurrentState]) {
case kShown:
[[self ShowHideButton] setTitle:@"Hide Panel" forState:UIControlStateNormal];
break;
case kHidden:
[[self ShowHideButton] setTitle:@"Show Panel" forState:UIControlStateNormal];
break;
default:
break;
}
}
@end
मैं कुछ सुपर बुनियादी लापता हूँ? क्या कोई मदद कर सकता है?
धन्यवाद!
संपादित करें: मैं कोशिश की है 2 और बातें:
समस्या 1. मुझे देता ऑन-स्क्रीन ऑफ स्क्रीन दृश्य लाने से संबंधित होना, ऑफ स्क्रीन LeftPanel के साथ शुरू के रूप में लगता है एक ही समस्या है।
2. कोड के माध्यम से कदम से एक्सकोड (शेर के लिए 4 बीटा) का कारण बनता है। विवरण यहां दिए गए हैं (प्रत्येक क्रैश के लिए समान):
/स्रोत कैश/डीवीटी फाउंडेशन/डीवीटीफाउंडेशन -867/फ्रेमवर्क/क्लासेस/फ़ाइलपाथ/डीवीटीफ़ाइलपाथ में असंतुलन विफलता।मीटर: 373 विवरण: विधि:: + _filePathForParent: fileSystemRepresentation: लंबाई: allowCreation: थ्रेड: {नाम = (शून्य), num = 55} संकेत: रिक्त स्ट्रिंग एक मान्य पथ वस्तु नहीं है कोई भी पश्व-अनुरेखन: 0 0x00000001068719a6 - [IDEAssertionHandler handleFailureInMethod: वस्तु: फ़ाइल का नाम: LineNumber: messageFormat: बहस:] (IDEKit में) 1 0x0000000105f3e324 _DVTAssertionFailureHandler (DVTFoundation में) 2 0x0000000105edd16f + [DVTFilePath _filePathForParent: fileSystemRepresentation: लंबाई: allowCreation:] (DVTFoundation में) 3 0x0000000105edcd4d + [DVTFilePath _filePathForParent: pathString:] (DVTFoundation में) 4 0x0000000105ede141 + [DVTFilePath फ़ाइलPathForPathStrin छ:] (DVTFoundation में) 5 0x00000001064a8dde - [IDEIndex queryProviderForFile: highPriority:] (IDEFoundation में) 6 0x000000010655193b - [IDEIndex (IDEIndexQueries) symbolsMatchingName: InContext: withCurrentFileContentDictionary:] (IDEFoundation में) 7 0x000000010aca6166 __68- [IDESourceCodeEditor symbolsForExpression : inQueue: completionBlock:] _ (IDESourceEditor में) 8 0x00007fff93fb490a _dispatch_call_block_and_release (libdispatch.dylib में) 9 0x00007fff93fb615a _dispatch_queue_drain (libdispatch.dylib में) 10 0x00007fff93fb5fb6 _dispatch_queue_invoke (libdispatch.dylib में) 11 0x00007fff93fb57b0 _dispatch_worker_thread2 block_invoke_01561 (libdispatch.dylib में) 12 0x00007fff8bb5e3da _pthread_wqthread (libsystem_c.dylib में)(Libsystem_c.dylib में) 91,363,210 13 0x00007fff8bb5fb85 start_wqthread
अद्यतन: स्क्रीन शॉट
पैनल दिखाया गया है (स्टार्टअप राज्य)
पैनल छिपा (बटन प्रेस के बाद सफल संक्रमण)
त्रुटि: दबाने बटन को फिर से का कारण बनता है विफलता