Objective C - 选择随机 NIB 文件?
您好,我想让我的应用程序选择一个随机 XIB 文件供选择,并排除其中 3 个。
HowToPlay *LetsPlay = [[HowToPlay alloc] initWithNibName:@"HowToPlay" bundle:nil];
LetsPlay.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:LetsPlay animated:YES];
[LetsPlay release];
所以我知道如何通过执行上述操作从 nib 文件加载,但我希望它能够选择一个随机文件,然后排除某些文件。
我想要排除的: 主视图控制器, FlipSideViewController, 我想要的玩法
: 问题1, 问题2, 等等...
我有什么想法可以做到这一点吗?
谢谢!。祝你有美好的一天
Hello I would like to have my app pick a randome XIB file to choose from, and exclude 3 of them.
HowToPlay *LetsPlay = [[HowToPlay alloc] initWithNibName:@"HowToPlay" bundle:nil];
LetsPlay.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:LetsPlay animated:YES];
[LetsPlay release];
So i know how to load from a nib file by doing the above, but i would like it to be able to pick a random one and then exclude certain ones.
The ones i want excluded:
MainViewController,
FlipSideViewController,
HowToPlay
Ones i want:
Question 1,
Question 2,
and so on....
Any ideas of how i can do this?
Thanks!. Have a great day
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将所需的笔尖名称(表示为
NSString
)放入NSArray
中,然后生成一个随机数并从数组中选取一个笔尖名称。You could put the nib names you want (represented as
NSString
) in aNSArray
, then generate a random number and pick up one nib name from the array.