iphone - Inserting an NSString into NSBundle's pathForResource? -


यह यूआईएमएजेव्यू को प्रभाव ड्रॉवर में एनिमेट करता है:

  if (((* प्रभाव *) [ impactarray objectAtIndex:। iv]) animframe == 70) {((UIImageView *) [impactdrawarray objectAtIndex:। iv]) छवि = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource: @ "explosionA71" ofType: @ "png"] ]; } अगर (((प्रभाव *) [impactarray objectAtIndex: iv]।) Animframe == 71) {((UIImageView *) [impactdrawarray objectAtIndex: iv])। छवि = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource: @ " विस्फोट ए 72 "प्रकार: @" पीएनजी "]]; }  

कुछ भी नहीं है इस के साथ प्रकट होता है:

  NSString * myString2 = [NSString stringWithFormat: @ "एक% d", ((प्रभाव *) [impactarray objectAtIndex :। iv]) animframe; । ((UIImageView *) [impactdrawarray objectAtIndex: iv]) छवि = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource: (@ "विस्फोट% d", myString2) ofType: @ "png"]];  

NSString (उदाहरण के लिए) का मेरा संदर्भ

  NSString * myString23 = [NSString stringWithFormat: @ "$% d", धन]; Moneylabel.text = myString23;  

मैं फ़ाइल नाम में एक वैरिएबल का उपयोग कैसे कर सकता हूं? सूचकांक द्वारा एक संसाधन फ़ोल्डर में एक छवि लोड करने का कोई तरीका है? जैसे कुछ imageByIndex: currentanimationframe ? मैं UIImage दस्तावेज़ में कुछ भी नहीं देख पाया।

टिप्पणियों के उत्तर:

  NSString * myString2 = [NSString stringWithFormat: @ "ए% डी", ((प्रभाव *) [प्रभावकारेंट ऑब्जेक्टअटइंडएक्स: iv])। एन्निफ्रेम]; ((UIImageView *) [impactdrawarray objectAtIndex: iv]) छवि = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource: [NSString stringWithFormat: @ "विस्फोट% d", myString2] ofType: @ "png"]]।  

और

  NSString * imagename = [NSString stringWithFormat: @ "एक% d", ((प्रभाव *) [impactarray objectAtIndex: iv])। animframe]; UIImage * myImage = [UIImage imageNamed: imagename]; ((UIImageView *) [प्रभाव ड्रॉवेयर ऑब्जेक्टआटइंडएक्स: iv])। छवि = myImage;  

दोनों संकलन और चलाते हैं, लेकिन छवि नहीं दिखाती।

< P> का प्रयोग करें + stringWithFormat: , बस आपके उदाहरण में:

  [[NSBundle mainBundle] pathForResource: [NSString stringWithFormat: @ "विस्फोट% d", myString2] ofType: @ "png"];  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -