Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19089] iOS: Clipboard does not support multiple items

GitHub Issuen/a
TypeImprovement
PriorityNone
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsclipboard, ios
ReporterDaniel Kunzler
AssigneeUnknown
Created2015-05-20T21:32:42.000+0000
Updated2018-02-28T19:55:50.000+0000

Description

Problem

When requesting Ti.UI.Clipboard.getData(), if the clipboard has several items (e.g. more than one image) it returns only one item. This is an improvement suggestion to support multiple items on clipboard, which is supported by iOS since at least version 5.0.

Test case


        var self = Ti.UI.createView();

	var lblId = Ti.UI.createLabel({
		text : 'No valid files were identified.',
		left : 8,
		right : 8,
		top : 32,
	});
	self.add(lblId);
	
	var imgFile=Ti.UI.createImageView({
		left:8,
		right:8,
		top:80,
		height:200,
	});
	self.add(imgFile);

	var tmrCheck = setInterval(function() {

        //now copy more than one image from iOS Photos (like attachment) and see the result
        //notice that Blob size and image refers to only one image

		if (Ti.UI.Clipboard.hasData('image')) {	
			imgFile.image=Ti.UI.Clipboard.getData('image');
			Ti.API.info(Ti.UI.Clipboard.getData('image').getSize());
			lblId.text = 'Media Identified!';
		}else{
			lblId.text ='No valid files were identified.';
		}
	}, 3000);

Attachments

FileDateSize
iOS Simulator Screen Shot 06.05.2015 17.22.43.png2015-05-20T21:32:43.000+0000198186

Comments

  1. Daniel Kunzler 2015-07-02

    The following Obj-C code gives the total number of items currently present in the clipboard:
       -(id)getDataCount:(id)arg
       {
           
           ENSURE_STRING_OR_NIL(arg);
           
           __block NSInteger result;
           TiThreadPerformOnMainThread(^{
               UIPasteboard *board = [UIPasteboard generalPasteboard];
               NSInteger size = board.numberOfItems;
               if (size > 0){
                    DebugLog(@"[DEBUG] DataCount: %d", size);
                    result = size;
               }else{
                   result =  0;
               }
           }, YES);
           
           return NUMLONG(result);
       }
       
  2. Matthew Delmarter 2016-06-02

    +10

JSON Source