Titanium中支持IOS设备的拖拽

本文介绍了一种通过第三方库TiDrop支持Titanium Appcelerator在iOS设备上的拖放操作的方法,详细解释了如何通过简单的代码集成TiDrop库来实现这一功能。
官方QA论坛中有人问及拖拽功能:

QA:http://developer.appcelerator.com/question/128143/several-items-drag-and-drop-functionality-support-for-ios

解决方案:[url=http://blog.clearlyinnovative.com/post/12712466716/titanium-appcelerator-quickie-drag-drop-on-ios-using]Solution posted here[/url](需要FQ)

通过一个第三方库函数来支持在ios设备的拖放操作,进一步加强titanium的功能。

TiDrop是一个opensource的库函数,可以从[url=https://github.com/mcongrove/TiDrop]这里[/url]下载。

[b]Example[/b]

Ti.include("TiDrop.js");

var tabGroup = Ti.UI.createTabGroup();

var window = Ti.UI.createWindow({
title: "Drag + Drop",
backgroundColor: "#FFF"
});

var tab = Ti.UI.createTab({
title: "Drag + Drop",
window: window
});

var box1 = Ti.UI.createView({
width: 100,
height: 100,
top: 10,
left: 10,
backgroundColor: "#7A0000"
});

var box2 = Ti.UI.createView({
width: 100,
height: 100,
top: 10,
left: 120,
backgroundColor: "#007A00"
});

var container1 = Ti.UI.createView({
width: 300,
height: 120,
top: 237,
left: 10,
backgroundColor: "#CCC",
items: 0
});

function yay(e) {
if(e.contained) {
e.source.top = 247;
e.source.left = 20;
}
}

TiDrop.init(box1, container1, yay);
TiDrop.init(box2, container1, yay);

window.add(container1);
window.add(box1);
window.add(box2);

tabGroup.addTab(tab);
tabGroup.open();
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值