Sunday, 8 September 2013

Button that takes me to a new UIViewController based on the content of a TextField not working

Button that takes me to a new UIViewController based on the content of a
TextField not working

I'm trying to make a button take me to a new UIViewController based on the
content of a textField, but when I run it and hit the button (with the
right condition in the text field to take me to the new UIViewController),
the screen blacks out. This is what I wrote in my .h and .m files. Can
anyone help me
@interface ViewController : UIViewController
- (IBAction)boton:(id)sender;
@property (strong, nonatomic) IBOutlet UITextField *texto;
@end



#import "ViewController.h"
#import "ViewController2.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize texto;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)boton:(id)sender {
if ([texto.text isEqualToString:@"1"]) {
ViewController2 *vc1=[[ViewController2 alloc]init];
[self presentViewController:vc1 animated:YES completion:nil];
}
}
@end

No comments:

Post a Comment