小编Afo*_*nso的帖子

如何自我调整大小UICollectionViewCell

我的目标是让Swift实现具有动态内容的UICollectionView,其中每个单元格都包含句子的一部分.句子的每个部分都可以由用户编辑.问题是句子的某些部分可能比容器本身长.使用sizeToFit不是一种替代方法,因为所有内容都应具有相同的字体大小,以保持整个集合视图的可读性.

现在我得到的行为,当我的句子的一部分长于容器时,如下: 如您所见,第三行具有前导省略号

如您所见,第三行具有前导省略号.

我想要实现的是以下内容,单元格的溢出部分应该像HTML中的span标记一样包装,如下所示: 第三行包装

这可能吗?我怎么能做到这样的事情?

ios uicollectionview uicollectionviewcell swift ios9

17
推荐指数
1
解决办法
413
查看次数

iOS 8:将具有模糊效果的UIVisualEffectView应用于紧凑模式下的模态PopOver

我试图像2014年的WWDC会议214那样制作一个popover.

所以我开始使用具有两个视图的IB构建我的应用程序,这两个视图通过"Present As Popover"segue连接,如下:

在此输入图像描述 弹出视图包含一个填充其超级视图的文本视图,具有以下约束: 在此输入图像描述

为了支持模态popover,可以使用以下代码:

func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
    return .OverFullScreen
}

func presentationController(controller: UIPresentationController, viewControllerForAdaptivePresentationStyle style: UIModalPresentationStyle) -> UIViewController? {

    let navigationController = UINavigationController(rootViewController: controller.presentedViewController)
    controller.presentedViewController.navigationItem.setRightBarButtonItem(UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Done, target: self, action: "done"), animated: true)

    return navigationController
}
Run Code Online (Sandbox Code Playgroud)

这给了我以下结果: 在此输入图像描述

然后我尝试添加具有模糊效果的UIVisualEffectView.起初我只是在显示的控制器视图中添加一个子视图,在检查了视图层次结构后,我意识到我的效果视图实际上是在我的文本视图之上,但是我的文本视图被正确放置了.所以我尝试了insertSubview:atIndex:这样的方法:

func presentationController(controller: UIPresentationController, viewControllerForAdaptivePresentationStyle style: UIModalPresentationStyle) -> UIViewController? {

    let effectView = UIVisualEffectView(effect: UIBlurEffect(style: .Light)) as UIVisualEffectView
    effectView.setTranslatesAutoresizingMaskIntoConstraints(false)
    controller.presentedViewController.view.insertSubview(effectView, atIndex: 0)

    let viewList : [String : UIView] = ["effectView" : effectView]

    let navigationController = UINavigationController(rootViewController: controller.presentedViewController)
    controller.presentedViewController.navigationItem.setRightBarButtonItem(UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Done, …
Run Code Online (Sandbox Code Playgroud)

popover swift ios8 uivisualeffectview uipresentationcontroller

7
推荐指数
1
解决办法
1790
查看次数

在UITextView上替换属性文本时保持自定义属性

我有一个可编辑的UITextView,它加载了一个属性String.此属性String加载了应用程序设置的自定义属性.出于这个原因,我总是将这些自定义属性添加到typingAttributestextView.

每当我打字它按预期工作文本,所加入的文字具有自定义属性集,但每当我使用的预测建议更换一个字,整个单词的设置没有自定义属性.

据我所知,每次以编程方式设置属性文本时,都会typingAttributes自动清除.因此,当选择预测建议时,文本会以编程方式设置,因此我丢失了所有自定义属性.

有没有办法解决?

uitextview nsattributedstring ios swift

7
推荐指数
1
解决办法
375
查看次数

ODI中的Java Beanshell的Jython变量

我有total_lines一个jython命令的变量,我需要在ODI变量的刷新命令上访问它.

with open('file.txt') as file_name:
        for total_lines, line in enumerate(file_name):
            pass
        print total_lines
total_lines += 1
Run Code Online (Sandbox Code Playgroud)

为此我想到了使用<@@>将它传递给Java Beanshell变量.像这样:在jython命令中:

<@int totallines = total_lines; @>
Run Code Online (Sandbox Code Playgroud)

在刷新命令中:

select '<@=totallines@>' from dual;
Run Code Online (Sandbox Code Playgroud)

这可能吗?如何将jython变量归属为beanshell变量?我有什么选择?

干杯

jython beanshell oracle-data-integrator

5
推荐指数
1
解决办法
1634
查看次数

iOS 9:如何使用自定义NSTextStorage更新UITextView中的属性内容

我正在使用an UITextView来显示带有自定义属性的属性字符串.出于这个原因,我决定实现自己的NSTextStorage,每次处理后我都可以插入自定义属性.

每当我需要显示UITextView我用来设置它的文本时这样:

textView.attributedText = mutableText

但是,通过使用我的新功能NSTextStorage,似乎更新attributedText它对UITextView没有任何影响,它只显示它创建的占位符文本.

如何将attributedText属性连接UITextView到存储在NSTextStorage?的attributesString中?为了实现这一目标,我需要在两个对象上覆盖哪些方法?

uitextview ios nstextstorage swift ios9

5
推荐指数
0
解决办法
271
查看次数