Switching to a new view display an image which is randomly selected
My goal is that when I switch to a new view, a random image is selected via the arc4random
function and displayed in the view instantaneously.
Can some one give me direction on how to achieve the instant execution of random function 开发者_运维百科selection process with out a button to prompt the random function process? Any examples of code, were should the code be placed, etc.
- (void)viewDidLoad
You can put your image selecting code in this function and when the nib is created and loaded control will pass to it.
Alternatively, you can use
-(void) viewWillAppear:(BOOL)animated
To have the image appear fresh each time you make the view visible.
Welcome to StackOverflow.
Try putting it in viewDidLoad or viewDidAppear.
See also: http://developer.apple.com/iphone/library/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html
Also, FYI, you will get more answers to your questions if the questions themselves are readable. It took me a couple of parses to understand your problem. Try spell checking and adding some grammar, you'd be amazed at the difference it'll make.
精彩评论