Ios 从其他视图更改标签
这主要是一个授权问题,因为我还在学习,不明白。我不知道如何着手创建我需要的代理 我知道有人问过类似的问题,但解决方案对我没有帮助。如何将视图1上标签的文本与视图2上UITextField的内容切换Ios 从其他视图更改标签,ios,uiviewcontroller,delegates,uitextfield,uilabel,Ios,Uiviewcontroller,Delegates,Uitextfield,Uilabel,这主要是一个授权问题,因为我还在学习,不明白。我不知道如何着手创建我需要的代理 我知道有人问过类似的问题,但解决方案对我没有帮助。如何将视图1上标签的文本与视图2上UITextField的内容切换 谢谢 在此代码段中,ChildViewController是您的View2,ParentViewController是您的View1 在ChildViewController.h文件中: @protocol ChildViewControllerDelegate <NSObject> -
谢谢 在此代码段中,ChildViewController是您的View2,ParentViewController是您的View1 在ChildViewController.h文件中:
@protocol ChildViewControllerDelegate <NSObject>
- (void)parentMethodThatChildCanCall:(NSString *)string; //pass back the string value from your textfield
@end
@interface ChildViewController : UIViewController
{
@property (weak, nonatomic) IBOutlet UITextField *myTextField;
}
@property (assign) id <ChildViewControllerDelegate> delegate;
@interface parentViewController <ChildViewControllerDelegate>
{
@property (strong, nonatomic) IBOutlet UILabel *myLabel;
}
在ParentViewController.h文件中:
@protocol ChildViewControllerDelegate <NSObject>
- (void)parentMethodThatChildCanCall:(NSString *)string; //pass back the string value from your textfield
@end
@interface ChildViewController : UIViewController
{
@property (weak, nonatomic) IBOutlet UITextField *myTextField;
}
@property (assign) id <ChildViewControllerDelegate> delegate;
@interface parentViewController <ChildViewControllerDelegate>
{
@property (strong, nonatomic) IBOutlet UILabel *myLabel;
}