2011-09-07 88 views
0
NSString *formatString = NSLocalizedString(@"%1$i of %2$i", @"Picture X out of Y total."); 
NSString *countTitle = [NSString stringWithFormat:formatString, currentIndex_ + 1, photoCount_, nil]; 
[self setTitle:countTitle]; 

在這段代碼顯示例的稱號。」 44" 22,這意味着22日的照片出來的44 我想添加標題,如‘專輯名稱+ countTitle’這上面的代碼,以便將成爲像,我想給專輯的名稱是「Flickr」如何設置標題

Ex。 「如何代碼將

回答

0

這很簡單,你只需要添加一個額外的格式字符串修飾符,並在你的stringWithFormat:像這樣(在albumName是正確的地方添加變量的名稱您album`):

NSString *formatString = NSLocalizedString(@"%@ %1$i of %2$i", @"Picture X out of Y total."); 
NSString *countTitle = [NSString stringWithFormat:formatString, albumName, currentIndex_ + 1, photoCount_, nil]; 
[self setTitle:countTitle]; 

也只是要注意,而不是使用整數%1$i%1$i,你可以只使用%d對於C整數您的格式字符串像這樣:

NSString *formatString = NSLocalizedString(@"%@ %d of %d", @"Picture X out of Y total."); 
NSString *countTitle = [NSString stringWithFormat:formatString, albumName, currentIndex_ + 1, photoCount_, nil]; 
[self setTitle:countTitle]; 
+0

WO g grt thnx夥計 –