开发者

how to set title

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];

in this code the title showing Ex." 22 of 44" that means 22nd photos out of 44 i w开发者_如何学Pythonant add title like "album name + countTitle" which is above in the code so that wil become like and i want to give the name of album is "Flickr"

Ex. "Flickr 22 of 44" how the code will be


That is pretty simple, you just need to add an extra format string modifier and add the variable in the correct place in your stringWithFormat: like so (where albumName is the name of your 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];

Also just to note, instead of using %1$i and %1$i for integers, you can just use %d for C Integers in your format string like so:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜