• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

iphone - 使用 segue 和 Storyboard从一个 Controller 移动到另一个 Controller

[复制链接]
菜鸟教程小白 发表于 2022-12-12 13:47:29 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我已经完成了 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-推荐答案


尝试在您的 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/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap