Objective C - Pick random NIB file?

本秂侑毒 提交于 2019-12-11 11:30:46

问题


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


回答1:


You could put the nib names you want (represented as NSString) in a NSArray, then generate a random number and pick up one nib name from the array.



来源:https://stackoverflow.com/questions/6621141/objective-c-pick-random-nib-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!