小编mat*_*son的帖子

UITableView布局弄乱推送segue和返回.(iOS 8,Xcode beta 5,Swift)

tldr; 自动约束似乎在push segue上中断并返回查看自定义单元格

编辑:我提供了一个github示例项目,显示发生的错误 https://github.com/Matthew-Kempson/TableViewExample.git

我正在创建一个应用程序,它需要自定义UITableCell的标题标签,以允许根据帖子标题的长度变化的行.单元格正确加载到视图中但是如果我按下一个单元格以将推送信号加载到包含WKWebView的视图中,您可以看到,如屏幕截图所示,单元格会立即移动到不正确的位置.通过UINavigationController的后退按钮加载视图时也会看到这一点.

在这个特殊的例子中,我按下了最后一个单元格,标题是"我在巴黎拍了两张照片",所有内容都正确加载.然后如下一个屏幕截图所示,在加载第二个视图的背景中,单元格都会因未知原因向上移动.然后,当我加载视图时,您可以看到屏幕稍微向上移动,我实际上无法滚动任何低于显示的值.这看起来是随机的,就像其他测试一样,当视图加载回来时底部单元格下方的空白区域不会消失.

我还包括一张包含细胞所具有的约束的图片.

图片(我需要更多的声誉才能在这个问题中提供图像,因此他们就在这张影片中):http://imgur.com/a/gY87E

我的代码:

自定义单元格中的方法,允许单元格在旋转时正确调整视图大小:

override func layoutSubviews() {
    super.layoutSubviews()

    self.contentView.layoutIfNeeded()

    // Update the label constaints
    self.titleLabel.preferredMaxLayoutWidth = self.titleLabel.frame.width
    self.detailsLabel.preferredMaxLayoutWidth = self.detailsLabel.frame.width
}
Run Code Online (Sandbox Code Playgroud)

tableview中的代码

override func viewDidLoad() {
    super.viewDidLoad()

    // Create and register the custom cell
    self.tableView.estimatedRowHeight = 56
    self.tableView.rowHeight = UITableViewAutomaticDimension
}
Run Code Online (Sandbox Code Playgroud)

用于创建单元格的代码

    override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
    if let cell = tableView.dequeueReusableCellWithIdentifier("LinkCell", forIndexPath: indexPath) as? LinkTableViewCell {

        // Retrieve the post and set details …
Run Code Online (Sandbox Code Playgroud)

uitableview swift ios8

40
推荐指数
4
解决办法
1万
查看次数

我可以对不同类中的方法使用相同的缓存名称来使用 ehcache 进行缓存吗

我在不同的类中创建了两个方法,并用注释对它们进行了@Cacheable注释,并给出了相同的缓存名称,如下所示:

class MyClass{
    @Cacheable(value="inScopeCache")
    public Products getProducts() { 
        //reading data from repository
    } 
}

class MyNewClass{
    @Cacheable(value="inScopeCache")
    public NewProducts getProducts() { 
        //reading data from repository..
    } 
}
Run Code Online (Sandbox Code Playgroud)

它会起作用吗?如果是的话怎么办?我已经在 spring xml 中正确定义了上述缓存。如果同时调用这两个方法会发生什么?

由于此方法没有参数,因此如何生成密钥?

谢谢哈里什

ehcache

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

在UILabel中显示HTML文本,性能问题.[iPhone SDK,iOS 8,Swift]

我试图在UILabel中显示格式正确的HTML文本并成功使用以下代码:

    // Create the html body
    var attributedHTMLBody = NSAttributedString(data: comment.bodyHTML.dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: false), options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil, error: nil)

    // Create the string including the text style
    var htmlString = String(format: "<div style='font-size: 16px; font-family: HelveticaNeue-Light;'>%@", attributedHTMLBody.string)

    // Create the final text to display
    var attributedHML = NSAttributedString(data: htmlString.dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: false), options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil, error: nil)

    // Set the text
    cell.commentLabel.attributedText = attributedHML

    // Find the locations of any links
    var mutableLinkArray = NSMutableArray()
    var mutableRangeArray = …
Run Code Online (Sandbox Code Playgroud)

ios tttattributedlabel swift

4
推荐指数
1
解决办法
7046
查看次数

正确实现实用程序类[Swift]

我正在清理我的代码,因为我的TableViewController课程变得相当充实和漫长.为了清理代码,我想创建一些为它们提供方法的实用程序类TableViewController.在我当前的实现中,这些方法/函数能够在main中更改变量TableViewController.以下是我当前设置的示例:

class FooImplementation: NSObject {
    var viewController: Foo

    init(viewController: TableViewController) {
        self.viewController = viewController
    }
}

class FooUtility1: FooImplementation {
    // Methods
}

class FooUtility2: FooImplementation {
    // Methods
}

class Foo: TableViewController {
    var fooUtility1: FooUtility1
    var fooUtility2: FooUtility2

    override viewDidLoad() {
        fooUtlity1 = FooUtility1(self)
        fooUtlity2 = FooUtility2(self)
    }

    // Use of the methods...
}
Run Code Online (Sandbox Code Playgroud)

是否有更好/普遍定义的创建和使用这些类的方法?这些类可以组合成一个Utility可以访问所有方法FooUtility1FooUtility2提供的类吗?

谢谢!

swift xcode6

3
推荐指数
1
解决办法
1862
查看次数

如何删除Datagrip中的其他控制台(2017.3.1)

我为我的"Dev"数据库创建了一些额外的控制台(参见绿色箭头),但是想要将它们清理干净,只留下原始控制台(参见蓝色箭头).

在此输入图像描述

这似乎是一件简单的事情,但它似乎是最困难的事情之一,不幸的是我无法解决这个问题!

datagrip

3
推荐指数
1
解决办法
590
查看次数

UILabel所需的高度取决于字符串长度(Swift,iOS 8)

我正在努力获得基于可接受的可变大小文本的UILabel所需的高度.经过几个小时的研究,我还没有找到一种可行的方法来实现这一目标.目前我的代码如下:

func getHeightForTitle(postTitle: NSString) -> CGFloat {
    // Get the height of the font
    let constraintSize = CGSizeMake(self.cellTextWidth, CGFloat.max)

    let attributes = [NSFontAttributeName: [UIFont.systemFontOfSize(16.0)]]
    let labelSize = postTitle.boundingRectWithSize(constraintSize,
        options: NSStringDrawingOptions.UsesLineFragmentOrigin,
        attributes: attributes,
        context: nil)

    return labelSize.height
}
Run Code Online (Sandbox Code Playgroud)

但是这会引发以下错误:

2014-08-02 12:09:37.370 Testing App[8365:351906] - [_TtCSs23_ContiguousArrayStorage00007FD26C15F708 pointSize]: unrecognized selector sent to instance 0x11e640050
Run Code Online (Sandbox Code Playgroud)

这总是在let labelSize = postTitle ...方法中抛出,我相信它归结为属性变量.但是我可能错了.任何帮助表示赞赏,非常感谢!

请注意:这适用于iOS 8 Swift开发项目.

nsstring uilabel swift ios8

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