Ios 在Objective上的代理之间传回信息
我需要在CameraSessionView之间传回NSMutableArray的照片;如何将相机拍摄的照片存储在NSMutableArray上,以及TableViewController如何将这些照片上载到DropBox。我使用代理和协议,但我尝试的所有方法。。。失败。 任何人都可以帮助我。我想我做错了一些小事。 我向您展示一些代码:Ios 在Objective上的代理之间传回信息,ios,objective-c,delegates,tableview,Ios,Objective C,Delegates,Tableview,我需要在CameraSessionView之间传回NSMutableArray的照片;如何将相机拍摄的照片存储在NSMutableArray上,以及TableViewController如何将这些照片上载到DropBox。我使用代理和协议,但我尝试的所有方法。。。失败。 任何人都可以帮助我。我想我做错了一些小事。 我向您展示一些代码: @protocol BView <NSObject> -(void) didclickonSubmit:(NSArray*) selected_arr
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
CameraSessionView.h
@class CameraSessionView;
@protocol CameraSessionViewDelegate <NSObject>
@optional
-(void)uploadPhotosFromCamera:(NSMutableArray*)photos;
@end
@property (nonatomic, weak) id <CameraSessionViewDelegate> delegado;
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
PhotosTableViewController.h
@interface PhotosTableViewController : UITableViewController <CameraSessionViewDelegate>
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
@接口PhotoTableViewController:UITableViewController
PhotosTableViewController.m
@property (nonatomic, strong) CameraSessionView *camera;
- (void)viewDidLoad
{
_camera = [CameraSessionView new];
[_camera setDelegado:self];
}
-(void)uploadPhotosFromCamera:(NSMutableArray*)photos
{
NSLog(@"UPFC");
for(int x=0; x < [photos count];x++)
{
NSLog(@"UPFC...");
UIImage *foto = [photos objectAtIndex:x];
if (foto.size.height > 1000 || foto.size.width > 1000)
foto = [self imageWithImage:foto scaledToScale:0.15f];
DBMetadata* datos = [TablaSubidas addFile:pathElemento];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSData *data = UIImageJPEGRepresentation(foto, 1.0);
[fileManager createFileAtPath:[self photoPath:datos] contents:data attributes:nil];
[elementosTabla insertObject:datos atIndex:0];
}
[self sincFotos];
[self.tableView reloadData];
}
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
@属性(非原子,强)CameraSessionView*摄像机;
-(无效)viewDidLoad
{
_摄像头=[CameraSessionView new];
[_摄像头设置delegado:self];
}
-(无效)从照相机上载照片:(NSMutableArray*)照片
{
自然科学日志(“UPFC”);
对于(int x=0;x<[照片计数];x++)
{
自然科学日志(@“UPFC…”);
UIImage*foto=[photos objectAtIndex:x];
如果(foto.size.height>1000 | | foto.size.width>1000)
foto=[自成像与图像:foto缩放比例:0.15f];
DBMetadata*datos=[TablaSubidas addFile:pathElemento];
NSFileManager*fileManager=[NSFileManager defaultManager];
NSData*data=UIImageJPEG表示法(foto,1.0);
[fileManager createFileAtPath:[自光路径:datos]内容:数据属性:nil];
[elementosTabla插入对象:datos atIndex:0];
}
[自我信使];
[self.tableView重载数据];
}
只希望当我按下“确定”按钮时,照片会发送回PhotoTableViewController,并上传到dropbox
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
onTapOKButton上的self.delegado始终为零
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
看起来很容易,但我跑不了。
如果有人能帮助我或推荐我任何教程,我非常感激
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
谢谢 一旦viewDidLoad结束,您的
CameraSessionView
实例将从内存中释放。您需要将其存储在PhotosTableViewController
中的属性中,以便将其保留
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
您的委托也应定义为弱,例如
@property (nonatomic,weak) id< CameraSessionViewDelegate >delegado;
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
如果未实现委派方法,这将防止应用程序崩溃。您的
CameraSessionView
实例将在viewDidLoad结束后立即从内存中释放。您需要将其存储在PhotosTableViewController
中的属性中,以便将其保留
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
您的委托也应定义为弱,例如
@property (nonatomic,weak) id< CameraSessionViewDelegate >delegado;
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
如果未实现委派方法,这将防止应用程序崩溃。您的
CameraSessionView
实例将在viewDidLoad结束后立即从内存中释放。您需要将其存储在PhotosTableViewController
中的属性中,以便将其保留
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
您的委托也应定义为弱,例如
@property (nonatomic,weak) id< CameraSessionViewDelegate >delegado;
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
如果未实现委派方法,这将防止应用程序崩溃。您的
CameraSessionView
实例将在viewDidLoad结束后立即从内存中释放。您需要将其存储在PhotosTableViewController
中的属性中,以便将其保留
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
您的委托也应定义为弱,例如
@property (nonatomic,weak) id< CameraSessionViewDelegate >delegado;
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
如果没有实现委托方法,这将防止应用程序崩溃。这对我来说很有效。所以,您可以直接实现它。希望,你会成功。哦首先,在没有摄像机活动的情况下进行检查。只需传递字符串的简单数组,即可测试委托
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
/*****************
#import <UIKit/UIKit.h>
@class CameraSessionView;
@protocol CameraSessionViewDelegate <NSObject>
@optional
-(void)uploadPhotosFromCamera:(NSMutableArray*)photos;
@end
@interface CameraSessionView : UIViewController
@property (nonatomic,weak) id< CameraSessionViewDelegate >delegado;
@end
#import "CameraSessionView.h"
@interface CameraSessionView ()
@property (nonatomic, strong) NSMutableArray* images;
@end
@implementation CameraSessionView
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(onTapOkButton)
forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"OK" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[self.view addSubview:button];
}
- (void)onTapOkButton{
NSLog(@"Save photos");
_images = [[NSMutableArray alloc]init];
[_images addObject:@"_images1"];
[_images addObject:@"_images2"];
//NSLog(@"from del:%@",_images);
if([self.delegado respondsToSelector:@selector(uploadPhotosFromCamera:)])
[self.delegado uploadPhotosFromCamera:_images];
[self onTapDismissButton];
}
-(void)onTapDismissButton{
[self.view removeFromSuperview];
}
@end
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
CameraSessionView.h文件
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
/*****************
#import <UIKit/UIKit.h>
@class CameraSessionView;
@protocol CameraSessionViewDelegate <NSObject>
@optional
-(void)uploadPhotosFromCamera:(NSMutableArray*)photos;
@end
@interface CameraSessionView : UIViewController
@property (nonatomic,weak) id< CameraSessionViewDelegate >delegado;
@end
#import "CameraSessionView.h"
@interface CameraSessionView ()
@property (nonatomic, strong) NSMutableArray* images;
@end
@implementation CameraSessionView
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(onTapOkButton)
forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"OK" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[self.view addSubview:button];
}
- (void)onTapOkButton{
NSLog(@"Save photos");
_images = [[NSMutableArray alloc]init];
[_images addObject:@"_images1"];
[_images addObject:@"_images2"];
//NSLog(@"from del:%@",_images);
if([self.delegado respondsToSelector:@selector(uploadPhotosFromCamera:)])
[self.delegado uploadPhotosFromCamera:_images];
[self onTapDismissButton];
}
-(void)onTapDismissButton{
[self.view removeFromSuperview];
}
@end
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
/*****************
#import <UIKit/UIKit.h>
@class CameraSessionView;
@protocol CameraSessionViewDelegate <NSObject>
@optional
-(void)uploadPhotosFromCamera:(NSMutableArray*)photos;
@end
@interface CameraSessionView : UIViewController
@property (nonatomic,weak) id< CameraSessionViewDelegate >delegado;
@end
#import "CameraSessionView.h"
@interface CameraSessionView ()
@property (nonatomic, strong) NSMutableArray* images;
@end
@implementation CameraSessionView
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(onTapOkButton)
forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"OK" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[self.view addSubview:button];
}
- (void)onTapOkButton{
NSLog(@"Save photos");
_images = [[NSMutableArray alloc]init];
[_images addObject:@"_images1"];
[_images addObject:@"_images2"];
//NSLog(@"from del:%@",_images);
if([self.delegado respondsToSelector:@selector(uploadPhotosFromCamera:)])
[self.delegado uploadPhotosFromCamera:_images];
[self onTapDismissButton];
}
-(void)onTapDismissButton{
[self.view removeFromSuperview];
}
@end
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
DetailViewController.m文件
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
/********
#import "DetailViewController.h"
#import "CameraSessionView.h"
@interface DetailViewController ()<CameraSessionViewDelegate>
@end
@implementation DetailViewController
- (void)viewDidLoad {
[super viewDidLoad];
CameraSessionView *Camara= [[CameraSessionView alloc]initWithNibName:@"CameraSessionView" bundle:nil];
[Camara setDelegado:self];
[self.navigationController pushViewController:Camara animated:YES];
}
-(void)uploadPhotosFromCamera:(NSMutableArray*)photos{
NSLog(@"success:%@",photos);
}
@end
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
#导入“DetailViewController.h”
#导入“CameraSessionView.h”
@接口详细信息ViewController()
@结束
@实现细节视图控制器
-(无效)viewDidLoad{
[超级视图下载];
CameraSessionView*Camara=[[CameraSessionView alloc]initWithNibName:@“CameraSessionView”捆绑包:nil];
[Camara setDelegado:self];
[self.navigationController pushViewController:Camara动画:是];
}
-(无效)从照相机上载照片:(NSMutableArray*)照片{
NSLog(@“成功:%@”,照片);
}
@结束
这对我很有用。所以,您可以直接实现它。希望,你会成功。哦首先,在没有摄像机活动的情况下进行检查。只需传递字符串的简单数组,即可测试委托
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
/*****************
#import <UIKit/UIKit.h>
@class CameraSessionView;
@protocol CameraSessionViewDelegate <NSObject>
@optional
-(void)uploadPhotosFromCamera:(NSMutableArray*)photos;
@end
@interface CameraSessionView : UIViewController
@property (nonatomic,weak) id< CameraSessionViewDelegate >delegado;
@end
#import "CameraSessionView.h"
@interface CameraSessionView ()
@property (nonatomic, strong) NSMutableArray* images;
@end
@implementation CameraSessionView
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(onTapOkButton)
forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"OK" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[self.view addSubview:button];
}
- (void)onTapOkButton{
NSLog(@"Save photos");
_images = [[NSMutableArray alloc]init];
[_images addObject:@"_images1"];
[_images addObject:@"_images2"];
//NSLog(@"from del:%@",_images);
if([self.delegado respondsToSelector:@selector(uploadPhotosFromCamera:)])
[self.delegado uploadPhotosFromCamera:_images];
[self onTapDismissButton];
}
-(void)onTapDismissButton{
[self.view removeFromSuperview];
}
@end
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
CameraSessionView.h文件
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
/*****************
#import <UIKit/UIKit.h>
@class CameraSessionView;
@protocol CameraSessionViewDelegate <NSObject>
@optional
-(void)uploadPhotosFromCamera:(NSMutableArray*)photos;
@end
@interface CameraSessionView : UIViewController
@property (nonatomic,weak) id< CameraSessionViewDelegate >delegado;
@end
#import "CameraSessionView.h"
@interface CameraSessionView ()
@property (nonatomic, strong) NSMutableArray* images;
@end
@implementation CameraSessionView
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(onTapOkButton)
forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"OK" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[self.view addSubview:button];
}
- (void)onTapOkButton{
NSLog(@"Save photos");
_images = [[NSMutableArray alloc]init];
[_images addObject:@"_images1"];
[_images addObject:@"_images2"];
//NSLog(@"from del:%@",_images);
if([self.delegado respondsToSelector:@selector(uploadPhotosFromCamera:)])
[self.delegado uploadPhotosFromCamera:_images];
[self onTapDismissButton];
}
-(void)onTapDismissButton{
[self.view removeFromSuperview];
}
@end
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
/*****************
#import <UIKit/UIKit.h>
@class CameraSessionView;
@protocol CameraSessionViewDelegate <NSObject>
@optional
-(void)uploadPhotosFromCamera:(NSMutableArray*)photos;
@end
@interface CameraSessionView : UIViewController
@property (nonatomic,weak) id< CameraSessionViewDelegate >delegado;
@end
#import "CameraSessionView.h"
@interface CameraSessionView ()
@property (nonatomic, strong) NSMutableArray* images;
@end
@implementation CameraSessionView
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(onTapOkButton)
forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"OK" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[self.view addSubview:button];
}
- (void)onTapOkButton{
NSLog(@"Save photos");
_images = [[NSMutableArray alloc]init];
[_images addObject:@"_images1"];
[_images addObject:@"_images2"];
//NSLog(@"from del:%@",_images);
if([self.delegado respondsToSelector:@selector(uploadPhotosFromCamera:)])
[self.delegado uploadPhotosFromCamera:_images];
[self onTapDismissButton];
}
-(void)onTapDismissButton{
[self.view removeFromSuperview];
}
@end
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
DetailViewController.m文件
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
/********
#import "DetailViewController.h"
#import "CameraSessionView.h"
@interface DetailViewController ()<CameraSessionViewDelegate>
@end
@implementation DetailViewController
- (void)viewDidLoad {
[super viewDidLoad];
CameraSessionView *Camara= [[CameraSessionView alloc]initWithNibName:@"CameraSessionView" bundle:nil];
[Camara setDelegado:self];
[self.navigationController pushViewController:Camara animated:YES];
}
-(void)uploadPhotosFromCamera:(NSMutableArray*)photos{
NSLog(@"success:%@",photos);
}
@end
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
#导入“DetailViewController.h”
#导入“CameraSessionView.h”
@接口详细信息ViewController()
@结束
@实现细节视图控制器
-(无效)viewDidLoad{
[超级视图下载];
CameraSessionView*Camara=[[CameraSessionView alloc]initWithNibName:@“CameraSessionView”捆绑包:nil];
[Camara setDelegado:self];
[self.navigationController pushViewController:Camara动画:是];
}
-(无效)从照相机上载照片:(NSMutableArray*)照片{
NSLog(@“成功:%@”,照片);
}
@结束
这对我很有用。所以,您可以直接实现它。希望,你会成功。哦首先,在没有摄像机活动的情况下进行检查。只需传递字符串的简单数组,即可测试委托
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
/*****************
#import <UIKit/UIKit.h>
@class CameraSessionView;
@protocol CameraSessionViewDelegate <NSObject>
@optional
-(void)uploadPhotosFromCamera:(NSMutableArray*)photos;
@end
@interface CameraSessionView : UIViewController
@property (nonatomic,weak) id< CameraSessionViewDelegate >delegado;
@end
#import "CameraSessionView.h"
@interface CameraSessionView ()
@property (nonatomic, strong) NSMutableArray* images;
@end
@implementation CameraSessionView
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(onTapOkButton)
forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"OK" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[self.view addSubview:button];
}
- (void)onTapOkButton{
NSLog(@"Save photos");
_images = [[NSMutableArray alloc]init];
[_images addObject:@"_images1"];
[_images addObject:@"_images2"];
//NSLog(@"from del:%@",_images);
if([self.delegado respondsToSelector:@selector(uploadPhotosFromCamera:)])
[self.delegado uploadPhotosFromCamera:_images];
[self onTapDismissButton];
}
-(void)onTapDismissButton{
[self.view removeFromSuperview];
}
@end
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
CameraSessionView.h文件
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
/*****************
#import <UIKit/UIKit.h>
@class CameraSessionView;
@protocol CameraSessionViewDelegate <NSObject>
@optional
-(void)uploadPhotosFromCamera:(NSMutableArray*)photos;
@end
@interface CameraSessionView : UIViewController
@property (nonatomic,weak) id< CameraSessionViewDelegate >delegado;
@end
#import "CameraSessionView.h"
@interface CameraSessionView ()
@property (nonatomic, strong) NSMutableArray* images;
@end
@implementation CameraSessionView
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(onTapOkButton)
forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"OK" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[self.view addSubview:button];
}
- (void)onTapOkButton{
NSLog(@"Save photos");
_images = [[NSMutableArray alloc]init];
[_images addObject:@"_images1"];
[_images addObject:@"_images2"];
//NSLog(@"from del:%@",_images);
if([self.delegado respondsToSelector:@selector(uploadPhotosFromCamera:)])
[self.delegado uploadPhotosFromCamera:_images];
[self onTapDismissButton];
}
-(void)onTapDismissButton{
[self.view removeFromSuperview];
}
@end
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
/*****************
#import <UIKit/UIKit.h>
@class CameraSessionView;
@protocol CameraSessionViewDelegate <NSObject>
@optional
-(void)uploadPhotosFromCamera:(NSMutableArray*)photos;
@end
@interface CameraSessionView : UIViewController
@property (nonatomic,weak) id< CameraSessionViewDelegate >delegado;
@end
#import "CameraSessionView.h"
@interface CameraSessionView ()
@property (nonatomic, strong) NSMutableArray* images;
@end
@implementation CameraSessionView
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(onTapOkButton)
forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"OK" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[self.view addSubview:button];
}
- (void)onTapOkButton{
NSLog(@"Save photos");
_images = [[NSMutableArray alloc]init];
[_images addObject:@"_images1"];
[_images addObject:@"_images2"];
//NSLog(@"from del:%@",_images);
if([self.delegado respondsToSelector:@selector(uploadPhotosFromCamera:)])
[self.delegado uploadPhotosFromCamera:_images];
[self onTapDismissButton];
}
-(void)onTapDismissButton{
[self.view removeFromSuperview];
}
@end
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
DetailViewController.m文件
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
/********
#import "DetailViewController.h"
#import "CameraSessionView.h"
@interface DetailViewController ()<CameraSessionViewDelegate>
@end
@implementation DetailViewController
- (void)viewDidLoad {
[super viewDidLoad];
CameraSessionView *Camara= [[CameraSessionView alloc]initWithNibName:@"CameraSessionView" bundle:nil];
[Camara setDelegado:self];
[self.navigationController pushViewController:Camara animated:YES];
}
-(void)uploadPhotosFromCamera:(NSMutableArray*)photos{
NSLog(@"success:%@",photos);
}
@end
@protocol BView <NSObject>
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id<BView> delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
#导入“DetailViewController.h”
#导入“CameraSessionView.h”
@接口详细信息ViewController()
@结束
@实现细节视图控制器
-(无效)viewDidLoad{
[超级视图下载];
CameraSessionView*Camara=[[CameraSessionView alloc]initWithNibName:@“CameraSessionView”捆绑包:nil];
[Camara setDelegado:self];
[self.navigationController pushViewController:Camara动画:是];
}
-(无效)从照相机上载照片:(NSMutableArray*)照片{