2009-03-29 13 views
49

कुछ पढ़ने के बाद, मैंने पाया है कि आप यूआईएसविच नियंत्रण पर टेक्स्ट और रंग को कस्टमाइज़ कर सकते हैं। मुझे उत्सुकता है कि क्या ये विधियां ऐप स्टोर में स्वीकृत और शामिल होने की कोशिश करने में समस्याएं पैदा करती हैं।कस्टम यूआईविच और ऐप स्टोर स्वीकृति

नमूना iPhone Developer's Cookbook Sample Code से लिया कोड:

// Custom font, color 
switchView = [[UICustomSwitch alloc] initWithFrame:CGRectZero]; 
[switchView setCenter:CGPointMake(160.0f,260.0f)]; 
[switchView setLeftLabelText: @"Foo"]; 
[switchView setRightLabelText: @"Bar"]; 
[[switchView rightLabel] setFont:[UIFont fontWithName:@"Georgia" size:16.0f]]; 
[[switchView leftLabel] setFont:[UIFont fontWithName:@"Georgia" size:16.0f]]; 
[[switchView leftLabel] setTextColor:[UIColor yellowColor]]; 

उत्तर

40

इस app की दुकान को प्रस्तुत के साथ समस्या पैदा नहीं होंगे। जब तक आप इन विगेट्स को बनाने/बदलने के लिए किसी भी निजी (अनियंत्रित) एपीआई का उपयोग नहीं करते हैं, तब तक आपको अंतर्निहित नियंत्रणों के कस्टम नियंत्रण या परिवर्तित संस्करणों का उपयोग करने की अनुमति है।

+3

इस कि मैं अपने प्रबंधकों को दिखा सकते हैं करने के लिए कोई सबूत/आधिकारिक बयान है? – Tomen

+16

ऐप स्टोर में लगभग हर ऐप इसका सबूत है। – lfalin

+0

@lfalin, ठीक है कि यह एक असाधारण का थोड़ा सा है। आप वास्तव में नहीं जानते कि दुकान पर अनुमोदित ऐप्स वास्तव में स्रोत कोड के बिना 'UISwitch' को अनुकूलित कर रहे हैं। वे ऐप्स 'UIButton' या' UISlider' या कुछ और अनुकूलित कर सकते हैं। सवाल विशेष रूप से 'यूआईएसविच' के बारे में था और मुझे लगता है कि पोस्टर क्या प्राप्त कर रहा था यह था कि कुछ अनुकूलन निजी एपीआई का उपयोग कर सकता है या नहीं। मैंने बाद में ओएस संस्करणों में परिवर्तित गैर-दस्तावेज सुविधाओं पर निर्भर नियंत्रणों को अनुकूलित करने के लिए वहां उदाहरण भी पाए हैं, और इस प्रकार तोड़ दिया। लेकिन, उन्हें ऐप्पल द्वारा मेरे ऐप्स में अनुमोदित किया गया था। – Nate

-30

इससे आपकी ऐप स्वीकृति के साथ समस्याएं पैदा होंगी। मुझसे पूछते हैं कि मैं कैसे पता: पी

मैं बस एक बुरा टिप्पणी एप्पल से आज मिला है। हम एक विकल्प की तलाश में हैं।

+7

यह पूरी तरह से गलत है – zpesk

+12

कृपया विस्तृत करें ताकि हम जान सकें कि आपका ऐप परेशानी में क्यों भाग गया। – JoePasq

7

कस्टम UISwitch नियंत्रण है कि मैं मेरे नियंत्रण की पृष्ठभूमि का रंग बदलने के लिए अनुमति देने के लिए बनाया पर एक नजर डालें। टेक्स्ट, फ़ॉन्ट या टेक्स्ट रंग को आसानी से बदलने के लिए आप उसी विधि का उपयोग कर सकते हैं।

custom uiswitch control

कोड Github पर उपलब्ध है और एक PSD कि तीन अलग-अलग PNG फ़ाइलें है कि नियंत्रण का उपयोग करता है के निर्माण के लिए प्रयोग किया जाता है शामिल हैं। आप जो भी प्रारूप चाहते हैं उसमें पीएनजी फाइलों को फिर से बनाने के लिए पीएसडी की सामग्री को संशोधित कर सकते हैं। नियंत्रण में उन्हें स्वैप करें और दूर जाओ।

+0

यह बहुत अच्छा है! एक बदलाव जो मैं सुझाता हूं वह प्रारंभिक समय पर प्रत्येक स्विच के लिए एक अलग पृष्ठभूमि सेट करने की अनुमति देगा। कुछ ऐप्स में, यह एक ही ग्राफ़िक के आधार पर सभी स्विच को समझ में नहीं आता है। – radven

+8

लिंक टूटा हुआ है :( – Nate

16

आप एक कस्टम स्विच (खुला स्रोत और उपयोग करने के लिए नि: शुल्क) के अपने कार्यान्वयन का आनंद सकता है ... यह किसी भी पाठ प्रदर्शित करते हैं, या आसानी से इसे उपवर्ग ट्रैक में अपने स्वयं के कस्टम छवियों आकर्षित करने के लिए करने के लिए स्विच की स्थापना की अनुमति देता है ... । http://osiris.laya.com/projects/rcswitch/

यह स्विच यह आसान एक छवि पाठ के बजाय आकर्षित करने के लिए बनाता है: मुख्य स्विच वर्ग उपवर्ग और इस तरह ड्रॉ विधि ओवरराइड, और अपनी छवि को स्वचालित रूप से एनिमेट किया जाएगा:

- (void)drawUnderlayersInRect:(CGRect)aRect withOffset:(float)offset inTrackWidth:(float)trackWidth 
{ 
    [onImage drawAtPoint:CGPointMake(floorf(aRect.origin.x + 13 + (offset - trackWidth)), floorf((self.bounds.size.height - onImage.size.height)/2.0))]; 
    [offImage drawAtPoint:CGPointMake(floorf(aRect.origin.x + 15.0 + (offset + trackWidth)), ceilf((self.bounds.size.height - offImage.size.height)/2.0))]; 
} 
+0

वैसे, उन लोगों के लिए जिन्होंने आरसीएसविच के मूल 1.0 संस्करण को डाउनलोड किया है, आप शायद मेरे द्वारा पोस्ट किए गए 1.1 संस्करण को अपडेट करने पर विचार करना चाहें। कुछ चित्रकारी बग्स जो खिंचाव वाली छवियों के साथ दिखाई देती हैं जो केवल दिखाई देती हैं आईफोन (वे आईपैड पर तय किए गए हैं, इसलिए शायद वे आईफोन ओएस 3.2 में तय हैं)। यह अद्यतन इन मुद्दों के आसपास काम करता है। –

-1

एप्पल प्रलेखन से : -

आप पर ऑन/ऑफ बटन को बनाने और प्रबंधित करने के लिए यूआईएसविच क्लास का उपयोग करते हैं, उदाहरण के लिए, एयरप्लेन मोड जैसी सेवाओं के लिए वरीयताओं (सेटिंग्स) में। इन वस्तुओं को स्विच के रूप में जाना जाता है।

UISwitch वर्ग एक संपत्ति और उसके /बंद राज्य को नियंत्रित करने के लिए एक विधि की घोषणा की। UISlider, जब उपयोगकर्ता manipulates स्विच नियंत्रण के साथ के रूप में ("flips" यह) एक UIControlEventValueChanged घटना उत्पन्न होता है, जो नियंत्रण में परिणाम है (अगर ठीक से विन्यस्त) एक कार्रवाई संदेश भेजने।

UISwitch वर्ग अनुकूलन योग्य नहीं है।

ऐप्पल कह रहा है कि वे अनुकूलन योग्य नहीं हैं, जिसका अर्थ हो सकता है कि आपका ऐप खारिज कर दिया गया हो।

0

एप्पल ह्यूमन इंटरफ़ेस दिशानिर्देश में, स्विच दस्तावेज में, एप्पल राज्य:

उन दो सरल, व्यासीय विरोध विकल्प है कि कुछ की स्थिति का निर्धारण देने के लिए एक तालिका पंक्ति में एक स्विच का उपयोग करें, इस तरह के हां/नहीं या चालू/बंद। मूल्यों की एक अनुमानित जोड़ी का उपयोग करें ताकि उपयोगकर्ता को पर नियंत्रण न हो ताकि यह पता चल सके कि अन्य मूल्य क्या है।

तो, हाँ, जब तक आप मूल्यों की अनुमानित जोड़ी (जैसे हां/नहीं) का उपयोग करते हैं, तब तक पाठ को बदलना ठीक है।

0

सबकुछ UISwitch करने की आवश्यकता नहीं है। एक सरल सरल समाधान जिसे मैंने कार्यान्वित किया है, UIView और स्लाइड इवेंट के साथ दो छवियों (चालू/बंद) के बीच टॉगल किया गया स्पर्श ईवेंट है।

सादर Dhanesh

1

मैं सिर्फ इस दृश्य बनाया है, और आप सवाल

आशा है कि यह मदद करता है

ज फ़ाइल देखा:

#import <UIKit/UIKit.h> 

@interface EDSwitch : UIView 
{ 
    UIButton* onButton,*offButton; 
    UIImageView* bg; 
} 

- (id)initWithText:(NSString*)on andText:(NSString*)off andDelegate:(id)delegate andOnSelector:(SEL)onSelector andOffSelector:(SEL)offSelector andBackgroundImage:(UIImage*)bgImage andStartingValue:(BOOL)b; 

@end 

और .m फ़ाइल:

#import "EDSwitch.h" 

@implementation EDSwitch 

- (id)initWithText:(NSString*)on andText:(NSString*)off andDelegate:(id)delegate  andOnSelector:(SEL)onSelector andOffSelector:(SEL)offSelector andBackgroundImage:  (UIImage*)bgImage andStartingValue:(BOOL)b 
{ 
self = [super initWithFrame:CGRectZero]; 
if (self) { 
    UILabel* onLabel = [[UILabel alloc] initWithFrame:CGRectMake(2, 8, 50, 20)]; 
    onLabel.text = on ; 
    onLabel.tag = 1; 
    onLabel.font = [UIFont fontWithName:kCalibri size:15]; 
    onLabel.textAlignment = UITextAlignmentCenter; 
    onLabel.textColor = [UIColor colorFromHexString:@"#009dd0"]; 
    onLabel.backgroundColor = [UIColor clearColor]; 
    [onLabel sizeToFit]; 
    [onLabel setWidth:onLabel.frame.size.width + 4]; 


    UILabel* offLabel = [[UILabel alloc] initWithFrame:CGRectMake(2, 8, 50, 20)]; 
    offLabel.text = off ; 
    offLabel.tag = 1; 
    offLabel.textAlignment = UITextAlignmentCenter; 
    offLabel.font = [UIFont fontWithName:kCalibri size:15]; 
    offLabel.textColor = [UIColor colorFromHexString:@"#009dd0"]; 
    offLabel.backgroundColor = [UIColor clearColor]; 
    [offLabel sizeToFit]; 
    [offLabel setWidth:offLabel.frame.size.width + 4]; 

    float high = MAX([offLabel.text sizeWithFont:offLabel.font].width,[onLabel.text sizeWithFont:onLabel.font].width) + 10; 

    onButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
    [onButton addTarget:self action:@selector(toggled:) forControlEvents:UIControlEventTouchUpInside]; 
    [onButton addTarget:delegate action:onSelector forControlEvents:UIControlEventTouchUpInside]; 
    offButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
    [offButton addTarget:self action:@selector(toggled:) forControlEvents:UIControlEventTouchUpInside]; 
    [offButton addTarget:delegate action:offSelector forControlEvents:UIControlEventTouchUpInside]; 

    [onButton setWidth:high]; 
    [onButton setX:0]; 
    [onButton addSubview:onLabel]; 
    [onLabel setWidth:high]; 
    [onLabel setX:0]; 

    [offButton setWidth:high]; 
    [offButton addSubview:offLabel]; 
    [offButton setX:high]; 
    [offLabel setWidth:high]; 
    [offLabel setX:0]; 

    bg = [[UIImageView alloc] initWithImage:bgImage]; 

    self.frame = CGRectMake(200, 200 , (high*2), 34); 
    self.layer.borderColor = [[[UIColor colorFromHexString:@"#009dd0"] colorWithAlphaComponent:0.5] CGColor]; 
    self.layer.borderWidth = 0.5; 
    self.layer.cornerRadius = 5; 
    [self setX:[UIApplication sharedApplication].keyWindow.frame.size.width - self.frame.size.width - 8]; 

    [self addSubview:bg]; 

    [bg setWidth:[self getWidth]]; 
    [bg setHeight:[self getHeight]]; 

    [self addSubview:onButton]; 
    [self addSubview:offButton]; 

    [onButton setHeight:[self getHeight]]; 
    [offButton setHeight:[self getHeight]]; 

    if(b){ 
     [onButton setBackgroundColor:[UIColor clearColor]]; 
     [offButton setBackgroundColor:[UIColor whiteColor]]; 
    } 
    else{ 
     [onButton setBackgroundColor:[UIColor whiteColor]]; 
     [offButton setBackgroundColor:[UIColor clearColor]]; 
    } 
} 
return self; 
} 

-(void)toggled:(UIButton*)sender{ 
if(sender == onButton){ 
    UILabel* l = (UILabel*)[onButton viewWithTag:1]; 
    l.textColor = [UIColor grayColor]; 
    [onButton setBackgroundColor:[UIColor clearColor]]; 
    l = (UILabel*)[offButton viewWithTag:1]; 
    l.textColor = [UIColor colorFromHexString:@"#009dd0"]; 
    [offButton setBackgroundColor:[UIColor whiteColor]]; 

} 
else{ 
    UILabel* l = (UILabel*)[offButton viewWithTag:1]; 
    l.textColor = [UIColor grayColor]; 
    [offButton setBackgroundColor:[UIColor clearColor]]; 
    l = (UILabel*)[onButton viewWithTag:1]; 
    l.textColor = [UIColor colorFromHexString:@"#009dd0"]; 
    [onButton setBackgroundColor:[UIColor whiteColor]]; 
} 
} 

@end 

उपयोग:

[[UIApplication sharedApplication].keyWindow addSubview:[[EDSwitch alloc] initWithText:@"aksdjaksdjh" andText:@"dasjdsaj" andDelegate:self andOnSelector:@selector(logon) andOffSelector:@selector(logoff) andBackgroundImage:[UIImage imageNamed:@"toggleBottom.png"] andStartingValue:YES]]; 

लाइव लंबी और समृद्ध,

eiran

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