我已经完成了 Apple 开发人员工具资源中的第一个教程,您可以在其中进行输入、标签和按钮,我想要做的是,当您按下按钮时,它会将您带到一个新场景,所以我已经设置了segue,我现在将其命名为“testPush”,当我按下按钮时,我实际上如何让它移动,我得到一个错误提示
**Thread 1: signal SIGABRT**
它回复的代码是这样的
return UIApplicationMain(argc, argv, nil, NSStringFromClass([HelloWorldAppDelegate class]));
任何人都有任何想法,我知道你需要添加代码才能使 segue 工作,但是我所看到的一切都没有意义,或者它只是一段代码,几乎没有关于你如何得到它的说明工作等。感谢您的所有帮助
您可能需要的其他东西我不确定
场景一被称为:HelloWorldViewController
场景二调用:HelloWorldViewController2
编辑
这是我脚本中的代码,您需要它,谢谢。
HelloWorldViewController.m
#import "HelloWorldViewController.h"
@interface HelloWorldViewController ()
@property (weak, nonatomic) IBOutlet UITextField *textField;
@property (weak, nonatomic) IBOutlet UILabel *label;
- (IBAction)changeGreetingid)sender;
@end
@implementation HelloWorldViewController
- (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)changeGreetingid)sender {
self.userName = self.textField.text;
NSString *nameString = self.userName;
if ([nameString length] == 0) {
nameString = @"World";
}
NSString *greeting = [[NSString alloc] initWithFormat"Hello, %@!", nameString];
self.label.text = greeting;
}
- (BOOL)textFieldShouldReturnUITextField *)theTextField {
if (theTextField == self.textField) {
[theTextField resignFirstResponder];
}
return YES;
}
@end
HelloWorldViewController.h
#import <UIKit/UIKit.h>
@interface HelloWorldViewController : UIViewController <UITextFieldDelegate>
@property (copy,nonatomic) NSString *userName;
@end
还有 main.m
#import <UIKit/UIKit.h>
#import "HelloWorldAppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([HelloWorldAppDelegate class]));
}
}
Best Answer-推荐答案 strong>
尝试在您的 IBAction 中添加 performseguewithidentifier ,如下所示:
- (IBAction)changeGreetingid)sender {
self.userName = self.textField.text;
NSString *nameString = self.userName;
if ([nameString length] == 0) {
nameString = @"World";
}
NSString *greeting = [[NSString alloc] initWithFormat"Hello, %@!", nameString];
self.label.text = greeting;
[self performSegueWithIdentifier"segueId" sender:nil];
}
这应该会为您推送新内容。
关于iphone - 使用 segue 和 Storyboard从一个 Controller 移动到另一个 Controller ,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/18466827/
|