initWithNibName 使用部分笔尖名称而不是完整笔尖名称
所以我想用笔尖初始化我的视图控制器,但是我不想使用笔尖的全名,仅使用前四个字符,因为其余字符会有所不同。
正如您在下面的代码中看到的,我的所有笔尖都遵循一种格式,格式为 1_somenumber_sometext。 Somenumber 替换为 xibNumber,xibNumber 是从 1 到 10 的数字,这是单独计算的,只是添加到笔尖名称中,无需担心。
NSString* xibName =[NSMutableString stringWithFormat:@"1_%@_sometext", xibNumber];
childController = [[CategoryOneDetailController alloc] initWithNibName:xibName bundle:nil];
有人可以帮助我吗?
So i want to initialise my view controller with a nib however i don't want to use the full name of the nib just the first four characters as the remaining characters vary.
As you can see below in my code all of my nibs follow a format the format is 1_somenumber_sometext. Somenumber is substituted with xibNumber, xibNumber is a number from 1 to 10 this is calculated seperately and just added into the nib name, no need to worry about it.
NSString* xibName =[NSMutableString stringWithFormat:@"1_%@_sometext", xibNumber];
childController = [[CategoryOneDetailController alloc] initWithNibName:xibName bundle:nil];
Can anyone help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 xibNumber 是数字(NSInteger 或 int),请将
%@
替换为%i
。如果是双精度型或浮点型,请使用%d
或%f
。%@
是用于表示对象的标记,因此它不适用于 NSInteger 或 int 等基本类型。If xibNumber is a number (NSInteger or int), replace that
%@
with%i
. If it is a double or float, use%d
or%f
.%@
is a token used to signify an object, so it won't work for primitive types like NSInteger or int.