如何设置标题
问题描述:
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。 “如何代码将
答
这很简单,你只需要添加一个额外的格式字符串修饰符,并在你的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];
WO g grt thnx伙计 –