Ios 使用委托方法时,标签未更新

Ios 使用委托方法时,标签未更新,ios,objective-c,delegates,protocols,uistoryboardsegue,Ios,Objective C,Delegates,Protocols,Uistoryboardsegue,我有两个viewController和iam,它们使用委托方法使用在第二个viewController中输入的文本更新第一个视图控制器中的标签 我的问题是在textfieldsecondViewController中输入的值没有被推入UILabelFirstVIewController 我的第一个ViewController.h #import "SecondViewController.h" @interface ViewController : UIViewController <C

我有两个viewController和iam,它们使用委托方法使用在第二个viewController中输入的文本更新第一个视图控制器中的标签

我的问题是在textfieldsecondViewController中输入的值没有被推入UILabelFirstVIewController

我的第一个ViewController.h

#import "SecondViewController.h"
@interface ViewController : UIViewController  <CustomDelegate>
@end
@protocol CustomDelegate <NSObject>

-(void)sendinfo:(NSString *)info;

 @end

 @interface SecondViewController : UIViewController

 @property (weak, nonatomic) id <CustomDelegate> userDelegate;

 @property (weak, nonatomic) IBOutlet UITextField *textField;
SecondViewController.h

#import "SecondViewController.h"
@interface ViewController : UIViewController  <CustomDelegate>
@end
@protocol CustomDelegate <NSObject>

-(void)sendinfo:(NSString *)info;

 @end

 @interface SecondViewController : UIViewController

 @property (weak, nonatomic) id <CustomDelegate> userDelegate;

 @property (weak, nonatomic) IBOutlet UITextField *textField;

您正在第二个viewController中创建另一个UIViewController,并且该代理被设置为您所处的viewController

要查看您的更改,您应该执行[self dismissViewControllerAnimated:YES completion:nil];在第二个ViewController中

例如:

- (IBAction)sendInfo:(id)sender {

  [self.userDelegate sendinfo:_textField.text];

  [self dismissViewControllerAnimated:YES completion:nil];
}

你想做什么??学习委托或学习通过数据??您是否可以检查self.userDelegate是否为零,_textField是否为零,_textField.text是否为零?代理设置是否正确?如何从第一个移动到第二个?