我需要当两个NSStrings相等时它导航下一个ViewControl和两个NSStrings不等于只显示警告。
NSString* foo = @"Foo";
NSString* bar = [NSString stringWithFormat:@"%@",foo];
if([foo isEqualToString:bar])
//it's redirect nextViewControl
else
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Message!" message:@"NOt Valid" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
所以请告诉我有关重定向到NextViewControl的任何想法。我知道Button被单击以重定向到NextViewControl。
SecondViewController *second=[[SecondViewController alloc]initWithNibName:nil bundle:nil];
[second setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentViewController:second animated:YES completion:NULL ];
但我不知道如何根据条件重定向到ViewControl。 谢谢高级。
答案 0 :(得分:0)
试试这个
NSString* foo = @"Foo";
NSString* bar = [NSString stringWithFormat:@"%@",foo];
if([foo isEqualToString:bar])
{
SecondViewController *second=[[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
[second setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentViewController:second animated:YES completion:NULL ];
}
//it's redirect nextViewControl
else
{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Message!" message:@"NOt Valid" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
}
我希望这对你有用。
答案 1 :(得分:0)
试试这个
NSString* foo = @"Foo";
NSString* bar = [NSString stringWithFormat:@"%@",foo];
if([foo isEqualToString:bar])
{
ViewController *second=[[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
[second setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentViewController:second animated:YES completion:nil ];
NSLog(@"hie");
}
else
{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Message!" message:@"NOt Valid" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
答案 2 :(得分:0)
NSString * str1 = @“下一步”; NSString * str2 = [NSString stringWithFormat:@“%@”,str1];
if ([str1 isEqualToString:str2])
{
SecondViewController *scrSecond = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
[self.navigationController pushViewController:scrSecond animated:YES];
}