当我添加时,请将文字写入我的UILabel,
Lorem, Ipsum, is simply, dummy text of, the printing, and typesetting industry.
现在,假设我的UILabel的宽度有限,但行数= 0(无限制),那么它将显示如下文字:
Lorem, Ipsum, is
simply, dummy text
of, the printing,
and typesetting
industry.
在这里,您可以看到换行是在空白处完成的,现在我希望它们更新,并且我只想在有换行符或逗号(,)时才需要换行符。那么,我该如何实现呢。
我的预期输出是
Lorem, Ipsum,
is simply,
dummy text of,
the printing,
and typesetti
ng industry.
答案 0 :(得分:1)
经过测试的解决方案
创建Entry.observe('before save', async (ctx) =>{
try {
ctx.instance.image = await Entry.upload(ctx.instance.images[0].src)
} catch(error){
return Promise.reject(error)
}
return Promise.resolve()
});
和text
空字符串
customText
如果以前的字符不是let text = "Lorem, Ipsum, is simply, dummy text of, the printing, and typesetting industry."
var customText = ""
customText
替换不可分隔的空格
来填充\u{00a0}
,
创建标签并将customText指定给其文本
text.characters.enumerated().forEach { (idx, character) in
let prevChar = text[text.index(text.startIndex, offsetBy: max(0, idx-1))]
if character == " " && prevChar != "," {
customText.append("\u{00a0}")
}
else {
customText.append(character)
}
}
答案 1 :(得分:0)
// "myAwesomeDropzone" is the camelized version of the HTML element's ID
var myDropzone = new Dropzone("#myAwesomeDropzone", {
/*
* This step isn't required.
success: function(file, response) {
file.previewElement.id = response.id;
}
*/
});
myDropzone.on('removedfile', function(file) {
var id = jQuery(file.previewElement).find('.dz-filename span').html();
// directly access the removing preview element and get image name to delete it from server.
// var id = file.previewElement.id;
$.ajax({
type: 'POST',
url: '<?php echo base_url('seller/deleteImagegalleryById'); ?>',
data: {id: id, '<?php echo $this->security->get_csrf_token_name(); ?>': '<?php echo $this->security->get_csrf_hash(); ?>'},
dataType: 'html'
});
var _ref;
return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
});
现在使用此字符串
答案 2 :(得分:0)
Swift 3.0
只需添加这样的文字。我已经对此进行了测试,在这里您可以使用预期的输出,但不要忘记根据此设置标签高度。
jQuery(document).ready(function() {
var showstate = readCookie('showstate');
if(showstate == 'shown')
{
jQuery("#notice").hide();
}
jQuery('#notice .close').click(function(e){
jQuery("#notice").fadeOut();
createCookie('showstate', 'shown');
});
});
答案 3 :(得分:0)
也许你应该继承UILabel,CustomLabel.You应该计算内容和逗号并添加\ n。