본문 바로가기

Apple - IPhone / IPod Touch

클립보드 복사, 붙여넣기

CopyFrom Source Code


[UIPasteboard generalPasteboard].image = image;




Collapse
-(IBAction)copyImageToPasteBoard{
UIPasteboard *appPasteBoard = [UIPasteboard pasteboardWithName:@"CopyFrom"
create:YES];
appPasteBoard.persistent = YES;

NSData *data = UIImagePNGRepresentation([UIImage imageNamed:@"Old-Time-Photo.jpg"]);
[appPasteBoard setData:data forPasteboardType:@"com.appshop.copyfrom.imagedata"];
}

-(IBAction)copyStringToPasteBoard{
UIPasteboard *appPasteBoard = [UIPasteboard pasteboardWithName:@"CopyFrom"
create:YES];
appPasteBoard.persistent = YES;
[appPasteBoard setString:textView.text];
}

PasteTo Source Code

Collapse
-(IBAction)pasteImageToPasteBoard{
UIPasteboard *appPasteBoard = [UIPasteboard pasteboardWithName:@"CopyFrom"
create:YES];
NSData *data = [appPasteBoard dataForPasteboardType:@"com.appshop.copyfrom.imagedata"];
imageView.image = [UIImage imageWithData:data];
}

-(IBAction)pasteStringToPasteBoard{
UIPasteboard *appPasteBoard = [UIPasteboard pasteboardWithName:@"CopyFrom"
create:YES];
textView.text = [appPasteBoard string];
}