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 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。