Reputation: 269
I have finished the first tutorial in the apple developer tool resources where you make an input, label and button what I want is to make it so when you press the button it takes you to a new scene so i have set up the segue, and i'd it as "testPush" now how do i actually get it to move when i push the button i get an error saying
**Thread 1: signal SIGABRT**
And the code that it is replying to is this
return UIApplicationMain(argc, argv, nil, NSStringFromClass([HelloWorldAppDelegate class]));
Anyone got any idea's i know u need to add in code for the segue to work however everything i have seen doesn't make sense or its jsut a block of code with little to none instruction on what it means how u get it to work etc. Thanks for any and all help
Other stuff you might need i'm not to sure Scene one is called: HelloWorldViewController Scene two is called: HelloWorldViewController2
EDIT
Heres the code from my scripts encase you need that thanks. HelloWorldViewController.m
#import "HelloWorldViewController.h"
@interface HelloWorldViewController ()
@property (weak, nonatomic) IBOutlet UITextField *textField;
@property (weak, nonatomic) IBOutlet UILabel *label;
- (IBAction)changeGreeting:(id)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)changeGreeting:(id)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)textFieldShouldReturn:(UITextField *)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
And main.m
#import <UIKit/UIKit.h>
#import "HelloWorldAppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([HelloWorldAppDelegate class]));
}
}
Upvotes: 2
Views: 516
Reputation: 6529
try adding a performseguewithidentifier
in your IBAction
, something like the following:
- (IBAction)changeGreeting:(id)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];
}
that should push the new for you.
Upvotes: 1