使用setTitle让我的UIButton消失

时间:2015-01-04 03:14:37

标签: ios objective-c uibutton

-(void)viewDidLoad
{

Category1Number = 2;
Category2Number = arc4random() %3;


switch (Category1Number) {
    case 0:
        [Category1 setTitle:(@"Sports") forState:UIControlStateNormal];

        break;
    case 1:
        [Category1 setTitle:(@"Films") forState:UIControlStateNormal];
        break;
    case 2:
        [Category1 setTitle:(@"Music") forState:UIControlStateNormal];
        break;

    default:
        break;
}

switch (Category2Number) {
    case 0:
        [Category2 setTitle:(@"Games") forState:UIControlStateNormal];
        break;
    case 1:
        [Category2 setTitle:(@"Geography") forState:UIControlStateNormal];
        break;
    case 2:
        [Category2 setTitle:(@"History") forState:UIControlStateNormal];
        break;

    default:
        break;
    }




[super viewDidLoad];

}

我正在使用Mark Healey制作测验应用程序的教程,但我似乎没有得到与他相同的结果。应该发生的是,当视图加载时,按钮标签应该根据arc4random方法随机改变。我几乎100%肯定我在故事板中正确连接了东西。

感谢任何帮助,谢谢!

0 个答案:

没有答案