开发者

push view controller based on value of UILabel

开发者 https://www.devze.com 2023-03-02 13:35 出处:网络
I have a pickerview with 2 components, I have a 3 button segmented control.Based on what the user selects between the pickerview and the segmented control, I have a UILabel that displays a string.I wo

I have a pickerview with 2 components, I have a 3 button segmented control. Based on what the user selects between the pickerview and the segmented control, I have a UILabel that displays a string. I wo开发者_StackOverflow中文版uld like to push a view controller based on what is displayed in the UILabel. Should I use a switch statement for this? How do I convert the string values into integer expressions for the switch statement to work?

switch (fooLabel.text) {
    case @"foo-bar":
        [self.navigationController pushViewController:exampleVC animated:YES];
        break;

    default:
        break;
}

thanks!


just use multiple if statements

if ([fooLabel.text isEqualToString:@"foo-bar"])
{
    //Show one
}
else if ([fooLabel.text isEqualToString:@"bar-foo"])
{
    //Show Other
}
else
{
    //Show Default
}
0

精彩评论

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

关注公众号