eXit_door 2013-02-19 07:20 采纳率: 0%
浏览 1775

从view1中修改view2的UItextField

在ViewController中,修改SecondViewControllerUITextView.text

如果它是NSString类型可以这么修改:

SVC.string = @"test";

出现两个问题:

  • messageBox.text没有修改
  • SVC.messageBox.text 返回(null)

ViewController.m:

 SecondViewController *SVC = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
 SVC.messageBox.text = @"changed";
 NSLog(@"SVC: %@", SVC.messageBox.text); // result = (null)

 [self presentViewController:SVC animated:YES completion:NULL];

SecondViewController.h:

#import <UIKit/UIKit.h>

@interface SecondViewController : UIViewController

@property (nonatomic) IBOutlet UITextView *messageBox;


@end

SecondViewController.m:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    self.messageBox.text = @"first";
}
  • 写回答

1条回答 默认 最新

  • 睡觉不盖被 2015-08-25 03:40
    关注

    建议楼主 断点一下试试 设置messageBox 的是你要设置的控件么 并且是否为空。ios中对空对象发送信息 不会发生异常

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器