2015-08-17 15 views
5

में विशेष वर्ण कैसे सेट करें I iphone 6 और 6Plus के लिए कस्टम कीबोर्ड पर काम कर रहा हूं। मैंने शिफ्ट कुंजी सक्रिय - निष्क्रिय या 123 और एबीसी कुंजी के लिए तर्क विकसित किया है। लेकिन मैं दिखाया गया सेब कीबोर्ड जैसे कस्टम प्रतीक भी प्रदर्शित करना चाहता हूं। कृपया छवि में जांचें।आईओएस कस्टमकीबोर्ड। कस्टम कीबोर्ड

enter image description here

वर्तमान में मैं लोअरकेस और अपरकेस 123 करने के लिए एबीसी को बदलने में सक्षम हूँ, लेकिन मैं कैसे इस विशेष वर्ण सेट कर सकते हैं। नोट: - मैंने जिथब पर बहुत डेमो खोजा लेकिन मैं किसी भी कस्टम कीबोर्ड में विशेष चरित्र नहीं देख पा रहा हूं।

यहाँ अपरकेस और एबीसी-123 बटन के लिए मेरे तर्क है।

-(void)UpparCase:(UIButton*)sender // To make caps or small letter 
{ 

sender.selected=!sender.selected; 
if(sender.selected) 
{ 
    if(isPortrait) 
    { 

    [self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"upparActive.png"] forState:UIControlStateNormal]; 
    } 
    else 
    { 
     [self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"Uppar_selctd_land.png"] forState:UIControlStateNormal]; 

    } 

    for(UIButton *key in self.ObjKeyLayout.ArryCharKey) 
    { 


     NSString *uppercaseString = [[key currentTitle] uppercaseString]; 

     [key setTitle:uppercaseString forState:UIControlStateNormal]; 

     [key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside]; 

    } 
    } 
    else 
    { 

    if(isPortrait) 
    { 

    [self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"UpperCase.png"] forState:UIControlStateNormal]; 
    } 
    else 
    { 
     [self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"Uppar_land.png"] forState:UIControlStateNormal]; 

    } 
    for(UIButton *key in self.ObjKeyLayout.ArryCharKey) 
    { 


     NSString *uppercaseString = [[key currentTitle] lowercaseString]; 

     [key setTitle:uppercaseString forState:UIControlStateNormal]; 

     [key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside]; 

     } 

    } 
} 

- (IBAction)action123:(UIButton*)sender // To set 123 and ABC 
{ 


sender.selected=!sender.selected; 

if(sender.selected) 
{ 

    [self.ObjKeyLayout.btn123Key setTitle:@"ABC" forState:UIControlStateNormal]; 
      int i=0; 

    for(UIButton *key in self.ObjKeyLayout.ArryCharKey) 
    { 

     [key setTitleColor:[UIColor clearColor] forState:UIControlStateNormal]; 
     NSLog(@"\n\n123isSelected\nI-%i\tArrayCharKey.Count:-%i",i,(int)self.ObjKeyLayout.ArryCharKey.count); 
     if(isPortrait) 
     { 
      NSLog(@"\n\n123isSelected\nI-%i\tArrayCharKey.Count:-%i\nArraySpecialImageKey.Count-%i\n",i,(int)self.ObjKeyLayout.ArryCharKey.count,(int)arrspecialImageKey.count); 
      [key setBackgroundImage:[UIImage imageNamed:[arrspecialImageKey objectAtIndex:i]] forState:UIControlStateNormal]; 




     } 
     else{ 

      [key setBackgroundImage:[UIImage imageNamed:[arrSpecialIpad objectAtIndex:i]] forState:UIControlStateNormal]; 

     } 

     [key setTitle:[NumKey objectAtIndex:i] forState:UIControlStateNormal]; 

     [key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside]; 
     i++; 
    } 
    } 
    else 
    { 
    [self.ObjKeyLayout.btn123Key setTitle:@"123" forState:UIControlStateNormal]; 
    int i=0; 
    for(UIButton *key in self.ObjKeyLayout.ArryCharKey) 
    { 


     [key setTitleColor:[UIColor clearColor] forState:UIControlStateNormal]; 


     if(isPortrait) 
     { 
      [key setBackgroundImage:[UIImage imageNamed:[arrKeyImages objectAtIndex:i]] forState:UIControlStateNormal]; 
     } 
     else 
     { 


      [key setBackgroundImage:[UIImage imageNamed:[keyIpad objectAtIndex:i]] forState:UIControlStateNormal]; 
     } 
     ; 

     NSString *uppercaseString = [arrAlphabet objectAtIndex:i]; 

     [key setTitle:uppercaseString forState:UIControlStateNormal]; 

     [key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside]; 
     i++; 
     // is123selected=NO; 
     } 
    } 

} 

उत्तर

1

मैं इस तरह के साथ मेरी समस्या निर्धारित किया है क्योंकि मैं भी चाबियों का छवियों सेट ।

@interface KeyboardViewController() 
{ 
    BOOL ABCselect; 
BOOL select123; 
BOOL keypng; 
BOOL checkactiveshift; 
} 

    -(void)UpparCase:(UIButton*)sender 
{ 

if (ABCselect==YES) { 
    if (isPortrait) { 


        [self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"key.png"] forState:UIControlStateNormal]; 
        [self.ObjKeyLayout.btnCapKey setTitle:@"" forState:UIControlStateNormal]; 
       } 
       else 
       { 
        [self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"special_land_key.png"] forState:UIControlStateNormal]; 
        [self.ObjKeyLayout.btnCapKey setTitle:@"" forState:UIControlStateNormal]; 
       } 
    int i=0; 
    // int j=0; 

    for(UIButton *key in self.ObjKeyLayout.ArryCharKey) 
    { 

     [key setTitleColor:[UIColor clearColor] forState:UIControlStateNormal]; 
     NSLog(@"\n\n123isSelected\nI-%i\tArrayCharKey.Count:-%i",i,(int)self.ObjKeyLayout.ArryCharKey.count); 
     if(isPortrait) 
     { 
      NSLog(@"\n\n123isSelected\nI-%i\tArrayCharKey.Count:-%i\nArraySpecialImageKey.Count-%i\n",i,(int)self.ObjKeyLayout.ArryCharKey.count,(int)arrspecialImageKey.count); 
      [key setBackgroundImage:[UIImage imageNamed:[arrspecialImageKey objectAtIndex:i]] forState:UIControlStateNormal]; 

      } 
     else{ 

      [key setBackgroundImage:[UIImage imageNamed:[arrSpecialIpad objectAtIndex:i]] forState:UIControlStateNormal]; 

     } 

     [key setTitle:[NumKey objectAtIndex:i] forState:UIControlStateNormal]; 

     [key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside]; 
     i++; 
     } 

    //select123=NO; 
    keypng=YES; 
    ABCselect=NO; 
    } 

    else if (select123==YES) 
    { 

    if(isPortrait) 
    { 

     [self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"Caps.png"] forState:UIControlStateNormal]; 
     [self.ObjKeyLayout.btnCapKey setTitle:@"" forState:UIControlStateNormal]; 

    } 
    else 
    { 
     [self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"Uppar_land.png"] forState:UIControlStateNormal]; 
     [self.ObjKeyLayout.btnCapKey setTitle:@"" forState:UIControlStateNormal]; 


    } 
    for(UIButton *key in self.ObjKeyLayout.ArryCharKey) 
    { 


     NSString *uppercaseString = [[key currentTitle] lowercaseString]; 

     [key setTitle:uppercaseString forState:UIControlStateNormal]; 

     [key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside]; 

    } 
    select123=NO; 
    keypng=NO; 
    checkactiveshift=YES; 

} 
else if (keypng==YES) 
{ 
    [self.ObjKeyLayout.btnCapKey setTitle:@"123" forState:UIControlStateNormal]; 
      //[self.ObjKeyLayout.btnCapKey setTitle:@"" forState:UIControlStateNormal]; 
      [self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"123.png"] forState:UIControlStateNormal]; 

    [self.ObjKeyLayout.btn123Key setTitle:@"ABC" forState:UIControlStateNormal]; 


      int i=0; 
      for(UIButton *key in self.ObjKeyLayout.ArryCharKey) 
      { 
       [key setTitleColor:[UIColor clearColor] forState:UIControlStateNormal]; 


       if(isPortrait) 
       { 
        [key setBackgroundImage:[UIImage imageNamed:[specialkey2 objectAtIndex:i]] forState:UIControlStateNormal]; 
       } 
       else 
       { 


        [key setBackgroundImage:[UIImage imageNamed:[specialkey2Ipad objectAtIndex:i]] forState:UIControlStateNormal]; 
       } 
       ; 
       [key setTitle:[spec2title objectAtIndex:i] forState:UIControlStateNormal]; 

       [key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside]; 
       i++; 
       // [self action123:(UIButton*)sender]; 
       // [self addGesturToKeyBoard]; 

       //isshiftselected=NO; 
       keypng=NO; 
       ABCselect=YES; 
       // [self action123:(UIButton*)sender]; 
      } 
    } 


    else if(!self.ObjKeyLayout.btnCapKey.isSelected){ 


    sender.selected=!sender.selected; 
    if(sender.selected) 
    { 
     shiftactive=YES; 

     if(isPortrait) 
     { 

      [self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"upparActive.png"] forState:UIControlStateNormal]; 
     } 
     else 
     { 
      [self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"Uppar_selctd_land.png"] forState:UIControlStateNormal]; 

     } 

     for(UIButton *key in self.ObjKeyLayout.ArryCharKey) 
     { 


      NSString *uppercaseString = [[key currentTitle] uppercaseString]; 

      [key setTitle:uppercaseString forState:UIControlStateNormal]; 

      [key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside]; 


     } 
      // [sender1 setSelected: NO]; 
      // shift=YES; 
     [sender setSelected: YES]; 
    } 

     else 
     { 

     if(isPortrait) 
     { 

      [self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"Caps.png"] forState:UIControlStateNormal]; 
     } 
     else 
     { 
      [self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"Uppar_land.png"] forState:UIControlStateNormal]; 

     } 
     for(UIButton *key in self.ObjKeyLayout.ArryCharKey) 
     { 


      NSString *uppercaseString = [[key currentTitle] lowercaseString]; 

      [key setTitle:uppercaseString forState:UIControlStateNormal]; 

      [key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside]; 

     } 
      // [sender1 setSelected: YES]; 

    } 

    } 
    else if (self.ObjKeyLayout.btnCapKey.isSelected) 
    { 
    if(isPortrait) 
    { 

     [self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"Caps.png"] forState:UIControlStateNormal]; 
    } 
    else 
    { 
     [self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"Uppar_land.png"] forState:UIControlStateNormal]; 

    } 
    for(UIButton *key in self.ObjKeyLayout.ArryCharKey) 
    { 


     NSString *uppercaseString = [[key currentTitle] lowercaseString]; 

     [key setTitle:uppercaseString forState:UIControlStateNormal]; 

     [key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside]; 

     } 
     // [sender1 setSelected: YES]; 
     self.ObjKeyLayout.btnCapKey.selected = !self.ObjKeyLayout.btnCapKey.isSelected; 


     } 
    } 

    - (IBAction)action123:(UIButton*)sender 
    { 


    // dummy=YES; 
    sender.selected=!sender.selected; 
    if(sender.selected) 
    { 
    // is123selected=YES; 
    //[self dummy]; 

    [self.ObjKeyLayout.btn123Key setTitle:@"ABC" forState:UIControlStateNormal]; 
    //[self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"key.png"] forState:UIControlStateNormal]; 
    ABCselect=YES; 
    [self UpparCase:(UIButton*)sender]; 

    int i=0; 
    // int j=0; 

    for(UIButton *key in self.ObjKeyLayout.ArryCharKey) 
    { 

     [key setTitleColor:[UIColor clearColor] forState:UIControlStateNormal]; 
     NSLog(@"\n\n123isSelected\nI-%i\tArrayCharKey.Count:-%i",i,(int)self.ObjKeyLayout.ArryCharKey.count); 
     if(isPortrait) 
     { 
      NSLog(@"\n\n123isSelected\nI-%i\tArrayCharKey.Count:-%i\nArraySpecialImageKey.Count-%i\n",i,(int)self.ObjKeyLayout.ArryCharKey.count,(int)arrspecialImageKey.count); 
      [key setBackgroundImage:[UIImage imageNamed:[arrspecialImageKey objectAtIndex:i]] forState:UIControlStateNormal]; 




     } 
     else{ 

      [key setBackgroundImage:[UIImage imageNamed:[arrSpecialIpad objectAtIndex:i]] forState:UIControlStateNormal]; 

     } 

     [key setTitle:[NumKey objectAtIndex:i] forState:UIControlStateNormal]; 

     [key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside]; 
     i++; 
    } 
    makeshift=NO; 
} 
else 
{ABCselect=NO; 
    [self.ObjKeyLayout.btn123Key setTitle:@"123" forState:UIControlStateNormal]; 
      select123=YES; 
    [self UpparCase:(UIButton*)sender]; 



    int i=0; 
    for(UIButton *key in self.ObjKeyLayout.ArryCharKey) 
    { 


     [key setTitleColor:[UIColor clearColor] forState:UIControlStateNormal]; 


     if(isPortrait) 
     { 
      [key setBackgroundImage:[UIImage imageNamed:[arrKeyImages objectAtIndex:i]] forState:UIControlStateNormal]; 
     } 
     else 
     { 


      [key setBackgroundImage:[UIImage imageNamed:[keyIpad objectAtIndex:i]] forState:UIControlStateNormal]; 
     } 
     ; 

     NSString *uppercaseString = [arrAlphabet objectAtIndex:i]; 

     [key setTitle:uppercaseString forState:UIControlStateNormal]; 

     [key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside]; 
     i++; 
     //is123selected=NO; 
     } 
    } 
    [self.ObjKeyLayout.btnCapKey setSelected: NO]; 

    } 
+1

हां, पूंजी अक्षरों के लिए अच्छा तर्क। –

2

आप NumKey में इसके बारे में दो सरणी, alphabetical के लिए एक और numerical

NSArray *NumKey; 

NSArray *arrAlphabet; 

अब के लिए अन्य ले:

NumKey=[[NSArray alloc]initWithObjects:@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"0", @"-", @"/", @":", @";", @"(", @")", @"$", @"&", @"@", @"\"", @".", @",", @"?", @"!",@"'",@"^", nil]; 

और arrAlphabet:

arrAlphabet = [[NSArray alloc]initWithObjects:@"Q", @"W", @"E", @"R", @"T", @"Y", @"U", @"I", @"O", @"P", @"A", @"S", @"D", @"F", @"G", @"H", @"J", @"K", @"L", @"Z", @"X", @"C", @"V", @"B",@"N",@"M", nil]; 

कुंजीपटल में 123 या ABC पर आईबीओलेट।

घटना को प्रोग्रामेटिक रूप से नीचे के रूप में जोड़ना।

[self.keybard.btnNumeric addTarget:self action:@selector(action123:) forControlEvents:UIControlEventTouchUpInside]; 

विधि 123ABC करने के लिए या ABC123 को

- (IBAction)action123:(UIButton*)sender 
{ 

    if([self.keybard.btnNumeric.titleLabel.text isEqualToString:@"123"]) 
    { 
     [self.keybard.btnCapital setTitle:@"#+=" forState:UIControlStateNormal]; 

     [self.keybard.btnNumeric setTitle:@"ABC" forState:UIControlStateNormal]; 
     int i=0; 
     for(UIButton *key in self.keybard.keyArray) 
     { 
      key.layer.cornerRadius = 6.0; 

      [key setTitle:[NumKey objectAtIndex:i] forState:UIControlStateNormal]; 

      [key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside]; 
      i++; 
     } 
    } 
    else 
    { 
     [self.keybard.btnCapital setTitle:@"⬆️" forState:UIControlStateNormal]; 

     [self.keybard.btnNumeric setTitle:@"123" forState:UIControlStateNormal]; 

     int i=0; 
     for(UIButton *key in self.keybard.keyArray) 
     { 

      strFirstCap = @"0"; 

      NSString *uppercaseString = [arrAlphabet objectAtIndex:i]; 

      [key setTitle:[uppercaseString lowercaseString] forState:UIControlStateNormal]; 

      [key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside]; 
      i++; 
     } 

    } 

} 

बदलने के लिए उत्पादन:

enter image description here

+0

रीप्ले के लिए धन्यवाद लेकिन मैंने इसे पहले से ही सेट कर दिया है। मैं विशेष चरित्र के बारे में जानना चाहता हूं। जैसे कि जब आप 123 पर क्लिक करते हैं तो कैप्स बटन के स्थान पर दिखाए गए विशेष चरित्र कुंजी और जब आप उस पर क्लिक करते हैं तो विशेष चरित्र जैसे $, यूरो या पाउंड आदि लोड और 123 विशेष चरित्र के स्थान पर सेट होते हैं। और जब आप एबीसी पर क्लिक करते हैं तो फिर कैप्स कुंजी दिखाई देती है। कृपया छवि में जांचें। –

+0

जब आप विशेष चरित्र बटन पर क्लिक करते हैं तो क्या होता है? –

+0

एक ही लॉगिन प्रतीकों की एक सरणी बनाते हैं। –

संबंधित मुद्दे