我有一个UICollectionView与一个包含单个UIImageView的单元格.我正在设置UIImageView frame.size以匹配单元格的frame.size,并在cellForItemAtIndexPath方法中明确要求UIImageView使用Aspect Fill和Clip Subview进行缩放:
let cell:UICollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! UICollectionViewCell
...
var imageView = UIImageView(image: self.eventImages[indexPath.row])
imageView.frame.size = cell.frame.size
cell.contentMode = UIViewContentMode.ScaleAspectFill
cell.clipsToBounds = true
imageView.contentMode = UIViewContentMode.ScaleAspectFill
imageView.clipsToBounds = true
cell.addSubview(imageView)
Run Code Online (Sandbox Code Playgroud)
结果是伸出的图像(图像A),但当我点击(点击)图像时,它"神奇地"解析了Aspect Fill&Clip Subviews (图像B).我似乎无法理解为什么只有在点击之后才发生这种情况,而不是第一次加载图像时.它们被异步提取到服务器,但缩放仅在轻击图像后发生(也没有实现抽头功能).
注意:UICollectionView在故事板视图控制器中设置,集合视图和可重用单元都启用了Aspect Fill和Clip子视图.


我正在以模糊背景效果模式呈现视图控制器.iOS 10/XCode 8引入了我的动画问题.这是演示代码:
let modalVC = ModalViewController(nibName: "ModalViewController", bundle: nil)
modalVC.modalTransitionStyle = .CrossDissolve
modalVC.modalPresentationStyle = .OverFullScreen
presentViewController(modalVC, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
viewDidLoad()在ModalViewController中添加函数模糊:
let blurEffect = UIBlurEffect(style: .Light)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = view.bounds
blurEffectView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
view.addSubview(blurEffectView)
view.sendSubviewToBack(blurEffectView)
Run Code Online (Sandbox Code Playgroud)
该ModalViewController有一个明确的背景下,我加入了BlurEffectView一个黑暗的模糊效果.以编程方式使用上一个代码段和Interface Builder进行尝试.
在iOS 8和9上,.CrossDissolve转换处理了"淡入淡出",但在iOS 10(设备和模拟器)上进行测试后,视图显示为黑色半透明背景颜色而不是模糊.
在之后.CrossDissolve动画完成,背景颜色变为实际的模糊效果的背景.任何想法为什么会这样?
还尝试layoutIfNeeded()在viewDidLoad()模态视图控制器的开头和结尾添加没有任何运气.我正在使用swift 2.3
在模拟器中为每个尺寸拍摄了截图,我只有4.7英寸(iphone 6)和5.5英寸(iphone 6 Plus)截图的问题.... 4英寸和3.5英寸上传没有问题.
错误状态:一个或多个屏幕截图的宽高比错误.有关更多信息,请参阅开发人员指南.
在Dev-Guide上说:
4.7-inch -> 750 x 1334 pixels for hi-res portrait
5.5-inch -> 1242 x 2208 pixels for hi-res portrait
Run Code Online (Sandbox Code Playgroud)
我的截图有这些尺寸,我把它们带到各自的模拟器中.有谁有类似的问题?
(已经尝试重命名屏幕截图,避免奇怪的角色,什么不是......没有成功)
我想通过Dockerfile将nodejs安装到基于debian的容器.我对那里的不同分布有点困惑.我得出结论,我想要最新的STABLE发行版.
现在,在nodesource/distributions#deb中有四种不同的发行版(v0.10,v0.12,v4.x,v5.x).据我所知,我需要v5.x(通过阅读这篇博文,以及我用Google搜索的其他随机内容).但是我找到的每个地方,人们都建议安装v0.12(也是最新的稳定版,或者LTS,我不确定),即使在nodejs.com官方网站发行版中发布的版本是截至此时的v5.0.0 .
所以,我有两种可能的安装方式,任何帮助(请详细说明一下,也许这是一个愚蠢的问题,但这对我来说有点混乱)
curl -sL https://deb.nodesource.com/setup_5.x | bash -
apt-get install -y nodejs
Run Code Online (Sandbox Code Playgroud)
要么
curl -sL https://deb.nodesource.com/setup_0.12 | sudo -E bash -
sudo apt-get install -y nodejs
Run Code Online (Sandbox Code Playgroud) 所以我有这个Dockerfile尝试以下列方式安装ImageMagick:
FROM ruby:2.4-alpine
...
RUN apk --update add imagemagick
...
Run Code Online (Sandbox Code Playgroud)
关键是容器无法识别file实用程序(用于内容类型检测).
本地环境(Mac OSX上,安装imagemagick有brew):
> file --version
file-5.25
magic file from /usr/share/file/magic
> convert --version
Version: ImageMagick 6.9.9-5 Q16 x86_64 2017-08-03
http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib
Run Code Online (Sandbox Code Playgroud)
Docker Alpine容器(使用shell访问docker exec -it CONTAINER_ID):
> file --version
sh: file: not found
> convert --version
Version: ImageMagick …Run Code Online (Sandbox Code Playgroud) imagemagick paperclip paperclip-validation docker alpine-linux
我对 Kotlin 相当陌生,并且在操作基本 JSON 字符串以访问其内容时遇到问题。JSON 字符串如下所示:
"{\"id\":24,\"name\":\"nope\",\"username\":\"unavailable1991\",\"profile_image_90\":\"/uploads/user/profile_image/24/23102ca5-1412-489d-afdf-235c112c7d8e.jpg\",\"followed_tag_names\":[],\"followed_tags\":\"[]\",\"followed_user_ids\":[],\"followed_organization_ids\":[],\"followed_podcast_ids\":[],\"reading_list_ids\":[],\"blocked_user_ids\":[],\"saw_onboarding\":true,\"checked_code_of_conduct\":true,\"checked_terms_and_conditions\":true,\"number_of_comments\":0,\"display_sponsors\":true,\"trusted\":false,\"moderator_for_tags\":[],\"experience_level\":null,\"preferred_languages_array\":[\"en\"],\"config_body_class\":\"default default-article-body pro-status-false trusted-status-false default-navbar-config\",\"onboarding_variant_version\":\"8\",\"pro\":false}"
Run Code Online (Sandbox Code Playgroud)
我试过使用 Gson 和Klaxon包,但没有任何运气。我最近使用 Klaxon 的尝试如下所示:
val json: JsonObject? = Klaxon().parse<JsonObject>(jsonString)
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误: java.lang.String cannot be cast to com.beust.klaxon.JsonObject
我还尝试"在字符串的开头和结尾修剪双引号 ( ),并删除所有反斜杠,如下所示:
val jsonString = rawStr.substring(1,rawStr.length-1).replace("\\", "")
Run Code Online (Sandbox Code Playgroud)
但是当运行相同的 Klaxon 解析时,我现在收到以下错误: com.beust.klaxon.KlaxonException: Unable to instantiate JsonObject with parameters []
任何将此字符串解析为对象的建议(有或没有 Klaxon)将不胜感激!这不要紧,如果结果是JsonObject,Map或自定义类,只要我可以访问解析JSON数据:)
我无法从货币代码(例如“美元”)中获取货币符号(例如“$”)。
我目前正在尝试这种方式:
NSString *code = [NSLocale ISOCurrencyCodes][indexPath.row];
NSLog(@"%@", [[NSLocale currentLocale] displayNameForKey:NSLocaleCurrencySymbol value:code]);
Run Code Online (Sandbox Code Playgroud)
结果接收(空)... 寻找从货币代码中获取货币符号的正确方法。
即使我还没有看到结果,我很确定这会给出重复的条目(例如,欧元区国家将被重复,最终会出现许多不同的“€”符号)。有没有更好的方法来解决这个问题?
编辑:我对 NSNumberFormatter 没有问题,我需要的是iOS 中支持的所有货币的列表,供用户选择一种(我将使用 NSNumberFormatter 处理正确货币的格式,没有问题)。
谢谢
ios ×4
iphone ×4
docker ×2
alpine-linux ×1
android ×1
currency ×1
debian-based ×1
dockerfile ×1
imagemagick ×1
klaxon ×1
kotlin ×1
localization ×1
node.js ×1
npm ×1
objective-c ×1
paperclip ×1
screen-size ×1
screenshot ×1
swift ×1
uiblureffect ×1
uiimageview ×1
xcode8 ×1