剪貼簿功能

2021-08-16 08:14:30 字數 2135 閱讀 3760

1,複製貼上字串

//這個是需要輸入的資訊,即是要複製的資訊

uitextfield *textfild = [[uitextfield alloc] init];

self.textfild = textfild;

textfild.placeholder = @"請輸入資訊";

textfild.font = [uifont systemfontofsize:17];

[textfild settextcolor:[uicolor redcolor]];

textfild.frame = cgrectmake(10, 60, [uiscreen mainscreen].bounds.size.width-20, 40);

textfild.borderstyle = uitextborderstyleroundedrect;

[self.view addsubview:textfild];

//把上面複製的資訊貼上到這個控制項中,用

uitextfield *textfild2 = [[uitextfield alloc] init];

self.textfild2 = textfild2;

textfild2.placeholder = @"請輸入資訊2";

textfild2.font = [uifont systemfontofsize:17];

[textfild2 settextcolor:[uicolor redcolor]];

textfild2.frame = cgrectmake(10, cgrectgetmaxy(textfild.frame)+10, [uiscreen mainscreen].bounds.size.width-20, 40);

textfild2.borderstyle = uitextborderstyleroundedrect;

[self.view addsubview:textfild2];

執行下面的方法會把textfild中的資訊貼上給textfild2
/**

共享的字串

*/- (void)sharensstring

2,複製貼上

//要被複製的

uiimageview *imageview1 = [[uiimageview alloc] init];

self.imageview1 = imageview1;

imageview1.frame = cgrectmake(10, cgrectgetmaxy(textfild2.frame)+10, 100, 100);

imageview1.contentmode = uiviewcontentmodescaleaspectfill;

imageview1.clipstobounds = yes;

imageview1.image = [uiimage imagenamed:@"wuyifan"];

[self.view addsubview:imageview1];

//貼上**

uiimageview *imageview2 = [[uiimageview alloc] init];

self.imageview2 = imageview2;

imageview2.frame = cgrectmake(10, cgrectgetmaxy(imageview1.frame)+20, 100, 100);

imageview2.contentmode = uiviewcontentmodescaleaspectfill;

imageview2.clipstobounds = yes;

[self.view addsubview:imageview2];

執行下面的方法把複製的貼上到imageview2上
/**

共享data資料

*/- (void)sharedata

3,剪貼簿和 url scheme之間的比較

剪貼簿不僅消耗記憶體,也需要額外的時間來讀寫,程式進入後台等狀態時,應當清除剪貼簿,pastedboard.items = nil;

操作剪貼簿

剪貼簿 一 將資料送到剪貼簿 1 記憶體配置 hglobal hglobal hglobal globalalloc ghnd gmem share,lstrlen ptext 1 sizeof tchar 為什麼不用malloc 在windows中執行的應用程式之間必須要共享剪貼簿所儲存的記憶體塊...

剪貼簿相關

public const int wm user 0x400 public const int wm cap edit copy wm user 30 dllimport user32.dll static extern bool sendmessage intptr hwnd,int wmsg,s...

TClipBoard剪貼簿示例

拷貝端 unit unit1 inte ce uses windows,messages,sysutils,variants,classes,graphics,controls,forms,dialogs,stdctrls,clipbrd,extctrls type tform1 class tfo...