开发者

Change view load random text in labels

I'm using the arc4random command to change between three randomly selected views. In those three views, I have four labels displaying random texts when clicking on a button. So the labels are empty when you go to a random view until the button is clicked. But I need the four different labels to already be开发者_开发问答 loaded with the random texts when going to the new view. How do I do that?


In your interface of randomly selected file put the following code.

In view1.h

    @interface view1
    {
        NSString *strValue;
        UILabel *lblText;
    }
    @property (nonatomic, retain) NSString *strValue;

In view1.m

    @synthesize strValue;
    - (void)viewDidLoad 
    {
         lblText.text = strValue;            
    }

In your main view, from where you are calling the random view set following code...

    - (void)btnClicked:(id)sender
    {
         view1 *objView1 = [[view1 alloc] initWithNibName:@"view1" bundle:nil];
         objView1.strValue = @"Random Text";
         [self.navigationController pushViewController:objView1 animated:TRUE];
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜