1. Proxy mode in IOS development use a lot of such as Uitableview,uicollectioin Proxy way, with too much, the surface of the consciousness is, entrust others to do things, help Viewcontroller to solve a series of problems, directly on the code:
In ChilderViewController.h:
#import <UIKit/UIKit.h>
@protocol childerviewcontrollerdlegate <nsobject>
- (void) GetColor: (uicolor *) color;
@end
@interface childerviewcontroller: uiviewcontroller
@property (nonatomic,weak)ID <childerviewcontrollerdlegate >delegate;
@end
In CHILDERVIEWCONTROLLER.M:
#import "ChilderViewController.h"
@interface childerviewcontroller ()
@end
@implementation Childerviewcontroller
-(void) viewdidload {
[Super viewdidload];
self. View. BackgroundColor = [uicolor whitecolor];
UIButton *button = [[UIButton alloc] initwithframe:cgrectmake(0, 100, 200, 50 )];
[Button addTarget:self action:@selector(show) forcontrolevents: UIControlEventTouchUpInside];
//Button.backgroundcolor = [Uicolor redcolor];
[Button settitlecolor: [uicolor blackcolor] forstate:uicontrolstatenormal ];
[Button settitle:@ " return to the calling agent " forstate:uicontrolstatenormal];
[self. View addsubview: button];
}
-(void) show {
[self. Delegate getColor: [uicolor redcolor]];
[self. Navigationcontroller poptorootviewcontrolleranimated:YES];
}
-(void) didreceivememorywarning {
[Super didreceivememorywarning];
//Dispose of any resources the can be recreated
}
In a mainvccongtroller push past Childerviewcontrller, click the button in Childerviewcontroller to change the background color of the root view:
Mainviewcontroller.m
#import "MainViewController.h"
#import "ChilderViewController.h"
@interface Mainviewcontroller () <childerviewcontrollerdlegate>
@end
@implementation Mainviewcontroller
-(void) viewdidload {
[Super viewdidload];
additional setup after loading the view from its nib.
}
-(void) didreceivememorywarning {
[Super didreceivememorywarning];
//Dispose of any resources, can be recreated.
}
-(void) GetColor: (uicolor *) color{
self. View. BackgroundColor = color;
NSLog(@ "Change color ...");
}
-(ibaction) OnClick: (ID) Sender {
childerviewcontroller *childervc = [[childerviewcontroller alloc]init];
CHILDERVC. delegate = self;
[self. Navigationcontroller pushviewcontroller: childervc animated:YES];
}
Development mode for iOS agent (delegate)