ios making a button change view when text field equals string

巧了我就是萌 提交于 2019-12-01 11:09:41

What you have seems fine as far as it goes. To make the comparison case-insensitive, you can use

if ([txt.txt localizedCaseInsensitiveCompare:@"passwordToSkipLevel1"] == NSOrderedSame) {
    // ...
}

To change ViewController... is this a storyboard-based design? If so, you could write

if ([txt.txt localizedCaseInsensitiveCompare:@"passwordToSkipLevel1"] == NSOrderedSame) {
    [self performSegueWithIdentifier:@"SegueToLevel2VC" sender:self];
}

where SegueToLevel2CV is the identifier you've given the segue that goes to the next level, typed in to Interface Builder when you constructed the storyboard.

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