2012-01-03 4 views
6

के लिए फोनगैप में कैसे स्थापित करूं, मुझे कोई उद्देश्य-सी नहीं पता, इसलिए मैं आईओएस ऐप बनाने के लिए फोनगैप का उपयोग कर रहा हूं। आईओएस के लिए फोनगैप में एक बड़ी गड़बड़ी है। कीबोर्ड में लगातार फॉर्म सहायक ('अगला', 'पिछला' और 'किया गया' बटन होता है।) इस पर छुटकारा पाने के तरीके पर वेब पर बहुत कम जानकारी है, इसके बारे में सभी स्टैक ओवरफ्लो प्रश्नों ने कहा कि यह व्यावहारिक रूप से था असंभव। लेकिन थोड़ी देर बाद मैंने इस ट्यूटोरियल पर ठोकर खाई। नीचे पैराग्राफ आपको बताता है कि इसे कैसे करें। और यह काम करता है, मैंने समाप्त ऐप को डाउनलोड और परीक्षण किया।मैं इस स्क्रिप्ट को आईओएस

लेकिन चूंकि मुझे नहीं पता कि एक्सकोड में या ऑब्जेक्टिव-सी में लगभग कुछ भी कैसे करना है, मुझे नहीं पता कि कोड के दो वर्गों में कौन सी फाइलें चलती हैं, वह ट्यूटोरियल में नहीं कहता है।

क्या कोई मुझे बता सकता है कि फोनगैप ऐप्स फ़ाइलों में यह कहां जाता है? मैं इसे बड़े पैमाने पर सराहना करता हूं, यह मुझे पूरे दिन परेशान कर रहा है।

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; 

और यह

RichTextEditorViewController *viewController = [[RichTextEditorViewController alloc] initWithNibName:@"RichTextEditorViewController" bundle:nil]; 
self.viewController = [[UINavigationController alloc] initWithRootViewController:viewController]; 

इसके अलावा इस

- (void)removeBar { 
    // Locate non-UIWindow. 
    UIWindow *keyboardWindow = nil; 
    for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) { 
     if (![[testWindow class] isEqual:[UIWindow class]]) { 
      keyboardWindow = testWindow; 
      break; 
     } 
    } 

    // Locate UIWebFormView. 
    for (UIView *possibleFormView in [keyboardWindow subviews]) {  
     // iOS 5 sticks the UIWebFormView inside a UIPeripheralHostView. 
     if ([[possibleFormView description] rangeOfString:@"UIPeripheralHostView"].location != NSNotFound) { 
      for (UIView *subviewWhichIsPossibleFormView in [possibleFormView subviews]) { 
       if ([[subviewWhichIsPossibleFormView description] rangeOfString:@"UIWebFormAccessory"].location != NSNotFound) { 
        [subviewWhichIsPossibleFormView removeFromSuperview]; 
       } 
      } 
     } 
    } 
} 

धन्यवाद!

+2

पद। Obj-c सीखें और आप बहुत खुश होंगे। –

उत्तर

16

मुझे इसे स्वयं करने की आवश्यकता पूरी हो गई है। मैं एक आईओएस डेवलपर हूं, लेकिन मल्टीप्लाफ्फ़्ट देव के लिए लागत कम रखने के लिए फोनगैप का उपयोग करने की आवश्यकता है।

वैसे भी, मैंने आपका कोड तय किया है। , जैसा कि मैंने लगता है, आप यह जानना चाहते Obj सी अपने समय बिताना चाहते हैं न, तो आप सिर्फ निम्नलिखित के साथ अपने MainViewController.m की सामग्री को बदलने की जरूरत है:

#import "MainViewController.h" 

@implementation MainViewController 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     // Custom initialization 
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; 
    } 
    return self; 
} 

- (void)didReceiveMemoryWarning 
{ 
    // Releases the view if it doesn't have a superview. 
    [super didReceiveMemoryWarning]; 

    // Release any cached data, images, etc that aren't in use. 
} 

#pragma mark - View lifecycle 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view from its nib. 
} 

- (void)viewDidUnload 
{ 
    [super viewDidUnload]; 
    // Release any retained subviews of the main view. 
    // e.g. self.myOutlet = nil; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    return [super shouldAutorotateToInterfaceOrientation:interfaceOrientation]; 
} 

- (void) removeBar { 
    // Locate non-UIWindow. 
    UIWindow *keyboardWindow = nil; 
    for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) { 
     if (![[testWindow class] isEqual:[UIWindow class]]) { 
      keyboardWindow = testWindow; 
      break; 
     } 
    } 

    // Locate UIWebFormView. 
    for (UIView *possibleFormView in [keyboardWindow subviews]) {  
     // iOS 5 sticks the UIWebFormView inside a UIPeripheralHostView. 
     if ([[possibleFormView description] rangeOfString:@"UIPeripheralHostView"].location != NSNotFound) { 
      for (UIView *subviewWhichIsPossibleFormView in [possibleFormView subviews]) { 
       if ([[subviewWhichIsPossibleFormView description] rangeOfString:@"UIWebFormAccessory"].location != NSNotFound) { 
        [subviewWhichIsPossibleFormView removeFromSuperview]; 
       } 
      } 
     } 
    } 
} 

- (void)keyboardWillShow:(NSNotification*) notification { 
    // remove the bar in the next runloop (not actually created at this point) 
    [self performSelector:@selector(removeBar) withObject:nil afterDelay:0]; 
} 

@end 

चेतावनी का एक शब्द के रूप में, यह एक सा है एक हैकी समाधान (लेकिन तब फोनगैप का उपयोग कर रहा है!), और आईओएस के भविष्य के संस्करणों में तोड़ सकता है। लेकिन मुझे लगता है कि जब हम इसकी बात करते हैं तो हम इसे ठीक करते हैं ...

+0

आपको बहुत बहुत धन्यवाद! –

+0

दोस्त, बहुत धन्यवाद! मुझे आश्चर्य है कि आपका जवाब मेरे पिछले googlings के माध्यम से नहीं आया था। यह उत्तर निश्चित रूप से अधिक अपवर्तनीय तरीके से योग्य है। – hasen

+0

यह कोशिश करने के बाद मैं एक छोटी सी समस्या में भाग गया। हालांकि यह प्रदर्शन से ब्लैक बार को हटा देता है, बार "अभी भी वहां" है, यह वेबव्यू स्क्रॉल को प्रभावित करता है। मतलब, यदि कुछ इनपुट फ़ील्ड उस बार के पीछे "पीछे" है, तो सिस्टम – hasen

0

कुंजीपटल के नियंत्रण को बढ़ाने के लिए कई फोनगैप प्लगइन्स हैं। यद्यपि मैंने इसका उपयोग नहीं किया है, फिर भी ऐसा लगता है कि आयनिक कीबोर्ड प्लगइन जो आप करने की कोशिश कर रहे हैं वह प्रदान कर सकता है।

"अगले, पिछले और किए गए बटन के साथ कीबोर्ड एक्सेसरी बार छुपाएं।" विधि: cordova.plugins.Keyboard.hideKeyboardAccessoryBar

यह जोड़ने के लिए: कॉर्डोबा प्लग-इन जोड़ते सलाह के https://github.com/driftyco/ionic-plugins-keyboard.git