मेरे FirstViewController
मैं अगर डिवाइस iPhone4 या iPhone5 है स्विच पृष्ठभूमि के लिए इस कोड लिखने है:स्विच पृष्ठभूमि छवि iphone5 - iphone4
फ़ाइल का नाम: [email protected]
bg-for4 @ 2x .png
bg-for4.png
- (void)viewDidLoad
{
[super viewDidLoad];
UIImage *backgroundImage = [[UIImage alloc] init];
if([[UIScreen mainScreen]bounds].size.height == 568)
{
backgroundImage = [UIImage imageNamed:@"bg-for5-568h"];
}
else
{
backgroundImage = [UIImage imageNamed:@"bg-for4"];
}
self.view.backgroundColor = [[[UIColor alloc] initWithPatternImage:backgroundImage] autorelease];
[backgroundImage release];
}
जब मैं अपने सिम्युलेटर पर अनुप्रयोग lanch, iphone5 के लिए पृष्ठभूमि डबल आकार, दृश्य से बाहर दिखा।
/* यह संकल्प * धन्यवाद/
यह देखें कि: http://stackoverflow.com/questions/12446990/how-to-detect-iphone-5-wodes-devices –
यह दोहरा आकार होगा क्योंकि यह डबल आकार है और आईओएस इसे फैलाएगा ताकि 1 पिक्सेल छवि का ग्राफ़िक फलक के 1.0 "पिक्सेल" में प्रदर्शित किया जाएगा जो रेटिना उपकरणों पर 2 हार्डवेयर पिक्सेल से अधिक फैला हुआ है।इस मुद्दे से निपटने के कई तरीके हैं। कोड की उस पंक्ति में "bg-for5-568h @ 2x" को "bg-for5-568h" में बदलने के लिए सबसे आसान है, लेकिन पीएनजी फ़ाइल का नाम न बदलें। –
बहुत बहुत धन्यवाद! अब सही काम करता है। – Jimmy