小编Sak*_*boy的帖子

使用UITableViewAutomaticDimension时,UITableView在begin/endUpdates之后跳转

问题:当我在底部的的UITableView(且仅当在底部)和tableView.beginUpdates()/ tableView.endUpdates()被调用时,UITableView跳了一点点.我不希望它这样做.

设置:我有一个UITableViewUITableViewCells将全部在不同的大小和我使用UITableViewAutomaticDimension大小的细胞.

示例: 当我在底部时UITableView,我选择一个单元格,随后调用tableView.beginUpdates()/ tableView.endUpdates(),UITableView滚动/跳起一点点.

有没有人找到一种方法来做到这一点,所以没有跳跃后呼叫tableView.beginUpdates()/ tableView.endUpdates()在结束时UITableView

暂时我正在UITableViewCells手动计算我的全部,但我宁愿不这样做,因为我想利用它UITableViewAutomaticDimension.

代码:

这里有一些代码来显示tableView.beginUpdates()/ 之间发生的事情tableView.endUpdates():

    tableView.beginUpdates()
    cell!.setNeedsUpdateConstraints()
    cell!.updateConstraintsIfNeeded()
    cell!.setNeedsLayout()
    cell!.layoutIfNeeded()
    tableView.endUpdates()
Run Code Online (Sandbox Code Playgroud)

我的观点会发现:

public override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)

    self.tableView.estimatedRowHeight = 150.0
    self.tableView.rowHeight = UITableViewAutomaticDimension


    self.tableView.reloadData()
    //Bug in 8.0+ forces us to call three extra …
Run Code Online (Sandbox Code Playgroud)

uitableview ios

24
推荐指数
3
解决办法
5667
查看次数

IBDesignable来自外部框架?

我想创建一些使用@IBDesignable@IBInspectable标签的自定义视图.我已将这些添加到我的框架中,然后将我的框架链接到我的测试应用程序.但是Designables从未出现在StoryBoard中.

如何使用@IBDesignable@IBInspectable从外部框架创建自定义视图?

您可以使用@IBDesignable,并@IBInspectable在从非嵌入式框架的应用程序?

谢谢.

storyboard ios ios-frameworks swift ibdesignable

15
推荐指数
4
解决办法
4885
查看次数

在 API 26 之前的设备上使用 XML 属性 paddingHorizo​​ntal?

android:paddingHorizontalAPI 26 ( Android O) 中引入的 XML 属性是否仅适用于26及以上版本?有支持版本吗?我要求我minSdkVersion远低于 26。

我的印象是Android Studio 3 中包含的Android Asset Packaging Tool 2.0 (AAPT2)可能会对此有所帮助。

来自 AAPT2 发行说明:

版本 2.16

aapt2 链接...

XML 文件的版本控制更加智能,使用一小组规则将特定的较新属性降级为它们的向后兼容版本。例如:android:paddingHorizo​​ntal 降级为 android:paddingLeft 和 android:paddingRight。

但是不知道如何使用 AAPT2,而且我没有找到太多关于如何使用它的信息,我只是看到提到它。我的要求甚至可能吗?

非常感谢任何帮助/答案。

更新:是的,它不适用于较低的 SDK 版本。

xml android aapt android-studio-3.0 android-8.0-oreo

11
推荐指数
2
解决办法
5268
查看次数

在使用具有不同片段/布局的视图寻呼机时如何传递片段参数?

目的:为了使用片段参数从一个沿字符串值传递TextView到一个新的片段TextView,但在使用ViewPager具有不同layouts/fragmentsFragmentPagerAdapter

问题:新片段永远不会从前一个片段接收片段参数。

我的设置:我有我的Activity托管ViewPagerFragmentPagerAdapter。我已经重写FragmentPagerAdapters getItem(int position)fragment根据ViewPager. 现在Fragments我的适配器中只有两个,但在克服这个障碍后会添加更多。我正在使用该newInstance()技术传递Fragment的参数,但没有传递任何内容。

相关代码

我的 FragmentPagerAdapter 代码:

//this is a variable that I pass in as the newInstanct() methods parameter,
// I update   this variable from my fragments constantly
public static String fragmentArgumentsValue = "";

mViewPager.setAdapter(new FragmentPagerAdapter(fm) {


            @Override
            public int getCount() {

                return NUMBER_OF_VIEWS; …
Run Code Online (Sandbox Code Playgroud)

java android android-fragments android-viewpager fragmentpageradapter

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

使用旧金山字体将HTML解析为NSAttributedString?(iOS 9)

我需要解析包含<b>(粗体),<i>(斜体)和<u>(下划线)标签的基本HTML字符串,没有别的,只是那些简单的标签.

现在,我只能得到<u>(下划线)标签在正确渲染NSAttributedString,使用新的时San FranciscoiOS 9.

我真的需要得到<b>(粗体)和<i>(斜体)渲染.

这是我正在做的事情:

let text = "<i>Any</i> <b>Text</b> <u>that's basic HTML</u>"
let font = UIFont.preferredFontForTextStyle(UIFontTextStyleBody)

let modifiedFont = NSString(format:"<span style=\"font-family: '-apple-system','HelveticaNeue'; font-size: %f \">%@</span>",
font.pointSize, text) as String

let data = (modifiedFont as NSString).dataUsingEncoding(NSUTF8StringEncoding)

let attributedString = try? NSAttributedString(data: data!, options:
            [ NSDocumentTypeDocumentAttribute : NSHTMLTextDocumentType,
                NSCharacterEncodingDocumentAttribute : NSUTF8StringEncoding,
                NSFontAttributeName : font ],
            documentAttributes: nil)
Run Code Online (Sandbox Code Playgroud)

但不幸的是,<i>(斜体)和<b>(粗体)标签永远不会渲染,只有 …

accessibility nsattributedstring uifont ios ios9

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

FirebaseMessagingService默认情况下是在后台运行吗?

FirebaseMessagingService在后台运行是否类似于IntentService运行方式?

我看到那些不在后台运行的FirebaseMessagingService扩展区Service,但是我想确定我是否应该在FirebaseMessagingService异步或同步中进行任何工作.

谢谢

android android-service firebase android-intentservice firebase-cloud-messaging

5
推荐指数
2
解决办法
3839
查看次数

Play youtube/vimeo video embedded in HTML in Android WebView

Hey So I'm trying to play youtube/vimeo videos embedded in HTML inside of a webview.

The typlical HTML will look like this:

<p>Here's some text from a server</p>
<p>This text goes inside of a webview</p>
<p>Sometimes there are iframe's with vimeo videos embedded in the HTML text like this:</p>

<iframe src="//player.vimeo.com/video/12345?title=0&amp;byline=0&amp;portrait=0" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>

<p>Sometimes there are iframe's with youtube videos embedded in the HTML text like this:</p>

<p><iframe width="640" height="360" src="//www.youtube.com/embed/-NwibJy9-Cg?feature=player_detailpage" frameborder="0" allowfullscreen></iframe></p>
Run Code Online (Sandbox Code Playgroud)

But no …

youtube video android vimeo webview

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

向框架请求位置许可?

我正在编写一个使用CoreLocation. 是否可以向框架请求位置许可并且单独向框架请求位置许可?

或者我是否必须向消费应用程序请求位置许可。

我问这个问题是因为任何以上的应用程序都需要iOS 8在应用程序的.NSLocationAlwaysUsageDescriptionNSLocationWhenInUseUsageDescriptioninfo.plist

快速回答:

您可以向框架请求位置许可(即self.locationManager.requestAlwaysAuthorization),但使用所述框架的消费应用程序必须提供其 中的NSLocationAlwaysUsageDescription/NSLocationWhenInUseUsageDescription密钥info.plist

info.plist core-location mapkit ios swift

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