我最近看到了这个项目,用户可以从自定义键盘上点击GIF,他们会看到一个"复制"的工具包.我有一个问题:
任何人都可以给我一些示例代码来使用.我理解如何使用UIPasteboard及其功能,但是当我在这个函数中输入UTI类型"public.png"时,我似乎无法使它工作:(我在Objective-c中注意到它是"@public.png ",但我放了"public.png"我在网上找不到这个来源了)
let imageURL = NSString(string:NSBundle.mainBundle().pathForResource("test", ofType: "png")!)
var data = NSData(contentsOfURL: NSURL(string:imageURL)!)
UIPasteboard.generalPasteboard().setData(data!, forPasteboardType: "public.png")
Run Code Online (Sandbox Code Playgroud) 我目前正在实施一个upvoting系统(在应用程序中不使用向下投票系统).我设法在我的应用程序中为Post模型创建了一个upvote属性.该属性的默认值为0,如下所示:
models.py
class User(UserMixin, Model):
username = CharField(unique= True)
email = CharField(unique= True)
password = CharField(max_length = 100)
joined_at = DateTimeField(default = datetime.datetime.now)
is_admin = BooleanField(default = False)
confirmed = BooleanField(default = False)
confirmed_on = DateTimeField(null=True)
class Meta:
database = DATABASE
order_by = ('-joined_at',)
def get_posts(self):
return Post.select().where(Post.user == self)
def get_stream(self):
return Post.select().where(
(Post.user == self)
)
@classmethod
def create_user(cls, username, email, password, is_admin= False, confirmed = False, confirmed_on = None):
try:
with DATABASE.transaction():
cls.create(
username = username,
email …Run Code Online (Sandbox Code Playgroud)