我试图让一个按钮根据 textField 的内容将我带到一个新的 UIViewController,但是当我运行它并点击按钮时(在文本字段中使用正确的条件将我带到新的 UIViewController),屏幕黑屏。这是我在 .h 和 .m 文件中写的内容。谁能帮助我(我正在使用故事板)
@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