我的iOS应用程序会不时检查联系人并将新内容导入到自己的数据库中.
我通过identifier字段检查该联系人是否已存在,通常由UUID填充:
CNContactStore *store = [CNContactStore new];
[store requestAccessForEntityType:CNEntityTypeContacts completionHandler:^(BOOL granted, NSError *error) {
if (granted) {
NSArray *keys = @[CNContactNamePrefixKey,
CNContactGivenNameKey,
CNContactMiddleNameKey,
CNContactFamilyNameKey,
CNContactInstantMessageAddressesKey];
NSString *containerId = store.defaultContainerIdentifier;
NSPredicate *predicate = [CNContact predicateForContactsInContainerWithIdentifier:containerId];
NSArray *cnContacts = [store unifiedContactsMatchingPredicate:predicate keysToFetch:keys error:&err];
for (CNContact *contact in cnContacts) {
...
NSString *contactId = [contact identifier];
[fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"uuid == %@", contactId]];
...
}
Run Code Online (Sandbox Code Playgroud)
有时标识符除了UUID包含:ABPerson字符串(例如9326A125-3C0A-494F-9E50-BBFCF1140EF0:ABPerson),并且此类联系仅出现一次.下次出现相同的联系,但与另一个UUID和没有:ABPerson.
因此,我的联系人导入器认为他们是2个不同的联系人并保存2次.
:ABPersonCNContact标识符中的字符串是什么?
我知道带有类的AddressBook框架ABPerson,但是我使用Contacts框架来处理设备联系人,为什么会:ABPerson …
我在下面有一些代码:
<?=
$form->field($model, 'phone_no')->textInput(
[
'placeholder' =>
'(Conditionally validated based on checkbox above, groovy!)'
]
)
?>
Run Code Online (Sandbox Code Playgroud)
哪个结果是HTML:
<div class="form-group field-contactform-phone_no">
<label class="control-label">Phone No
<input type="text" aria-describedby="hint-contactform-phone_no" placeholder="(Conditionally validated based on checkbox above, groovy!)" name="ContactForm[phone_no]" id="contactform-phone_no" class=""></label>
<small class="error-box"></small>
<p class="help-text" id="hint-contactform-phone_no"></p>
</div>
Run Code Online (Sandbox Code Playgroud)
我的问题是:
如何在外部div中添加一个"隐形"类(当前包含class = form-group)?
感谢帮助
例如,我有这样的看法:
import SwiftUI
struct TarifsScreen: View {
var body: some View {
GeometryReader { geometry in
VStack {
VStack {
Spacer()
Text("Text1")
Spacer()
Text("Text2")
Spacer()
Text("Text3")
Spacer()
}
}
.frame(width: geometry.size.width, height: geometry.size.height)
.shadow(color: Color.white, radius: 10, x: 0, y: 0)
}
}
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能只为VStack,而不是为里面的所有元素应用阴影VStack?我可以用ZStack和两个容器来做吗?
我有使用自定义参数定义的字体:
public var suiFont: Font {
.custom(name, size: size)
}
Run Code Online (Sandbox Code Playgroud)
然后我需要使用它们来创建UIKit's UIFont。如何从Font结构体中获取参数?我找到了标准字体的解决方案:
UIFont.preferredFont(forTextStyle: .body).pointSize
UIFont.preferredFont(forTextStyle: .body).fontName
UIFont.preferredFont(forTextStyle: .body).fontDescriptor
Run Code Online (Sandbox Code Playgroud)
但它不适合我的情况,因为我的字体是使用自定义参数创建的。例如Font.custom("SFUI", size: 25)返回尺寸 17。
还有其他方法可以从 SwiftUI Font 获取字体参数吗?标准 SwiftUI 元素如何使用包装的 UIKit 元素来做到这一点?
我有Jenkins服务器用于autobuilding iOS项目,有两个目标.使用命令行实用程序构建项目xcodebuild.
完整的命令是
/usr/bin/xcodebuild -workspace "Our project.xcworkspace"
-scheme "First target"
-configuration Release
archive
DEVELOPMENT_TEAM=TEAMCODE
-allowProvisioningUpdates
和
/usr/bin/xcodebuild -workspace "Our project.xcworkspace"
-scheme "Second target"
-configuration Release
archive
DEVELOPMENT_TEAM=TEAMCODE
-allowProvisioningUpdates
在我将Xcode更新到版本10之前,它完美无缺.但每次更新后我都会看到错误
错误:Fabric:Info.plist错误
无法在路径/Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/Our_project-xxxx/Build/Intermediates.noindex/ArchiveIntermediates/Our project/BuildProductsPath/Release-iphoneos/First application.app/Info中处理Info.plist .plist这可能是一个计时问题,确保Fabric运行脚本构建阶段是最后一个构建阶段,没有其他脚本已经移动我们的application.app从Xcode生成它的位置.您还可以为Fabric运行脚本构建阶段添加'$(BUILT_PRODUCTS_DIR)/ $(INFOPLIST_PATH)'作为"输入文件"依赖项.
**存档失败**
在谷歌搜索和阅读错误说明后,我Build phases在Xcode中打开了标签并进行了设置(将Run script项目移至底部,检查Run script only when installing并添加$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)到输入文件并删除空Run script项目).
从命令行手动构建现在可以工作 - 看起来问题已经解决了.甚至詹金斯确实建立了第一个目标!但是,secong目标并没有出现同样的错误.
我做了打开项目,看看Build阶段选项卡,看到该Run script项目移到上面,Run script出现了新的空白.之后我做了实验:设置构建阶段,在Xcode GUI中重建项目,并看到阶段再次重新排序.因此,它发生在建造期间或之后.
我该如何解决这个错误?
说,我可以从命令行手动订购构建阶段吗?如果是,我只是在Jenkins步骤中添加行.
此外:此错误仅出现在命令行构建中.当我从Xcode GUI构建项目时,它总是成功的.
我开发了多语言iOS项目,其中包含以下UI元素的翻译%LANG%.lproj/%STORYBOARD_NAME%.strings:
/* Class = "UINavigationItem"; title = "User information"; ObjectID = "yXU-vS-01l"; */
"yXU-vS-01l.title" = "User information";
Run Code Online (Sandbox Code Playgroud)
当UI元素没有翻译时,Xcode会在控制台中写入警告:
Localizable string "yXU-vS-01l.title" not found in strings table "Main" of bundle CFBundle (executable, loaded).
但是一些元素仅在运行时获取其值,并且不需要故事板翻译.
如何禁用此类元素的警告?现在我看到两种方式:
将可本地化的值设置为空字符串
它有助于导航项或具有可见边界的其他元素,但作为标签和按钮的元素在设计时将不可见,也可以调整为零宽度
向*.strings文件添加虚拟翻译
当支持语言的数量增加时,将太过于及时
可能存在另一种方式?例如,为UI元素设置一些属性?
我已经尝试过这个问题的解决方案:生成resource_bundle_accessor,类型“Bundle”没有成员“模块”,但它仍然不起作用。
我正在尝试在单元测试中访问一个简单的 JSON 文件。这是我的 Package.swift:
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "MyLibrary",
platforms: [.iOS("11.0"), .macOS(SupportedPlatform.MacOSVersion.v10_12)],
products: [
.library(name: "MyLibrary", targets: ["MyLibrary"])],
dependencies: [],
targets: [
.target(name: "MyLibrary", dependencies: []),
.testTarget(
name: "MyLibraryTests",
resources: [
.process("recommendations.json"
],
dependencies: ["MyLibrary"]
),
]
)
Run Code Online (Sandbox Code Playgroud)
recommendations.json到我的 package.swift 中。我已经关闭并重新打开 Xcode 5 次,但仍然没有创建扩展Bundle.module。这是我的文件结构:
如何在单元测试中访问我的 JSON 文件?
Objective C具有预处理器,Swift具有允许在不同环境中使用不同代码的编译条件,例如用于调试或发布构建:
#if DEBUG
print("debug message")
doDebugAction()
#else
doReleaseAction()
#endif
Run Code Online (Sandbox Code Playgroud)
我可以添加仅针对 SwiftUI 预览进行编译的代码吗?就像是:
#if targetEnvironment(swiftUIPreview)
static func mock() -> SomeStruct {
// fill random data
}
#endif
Run Code Online (Sandbox Code Playgroud) 我试图弄清楚是否有任何方法可以检测是否shift按下了键,或者在shift按下键时是否发送了任何通知UIKeyboard
- (BOOL) textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)string
Run Code Online (Sandbox Code Playgroud)
不会因为shift按键而被调用,因为它是一个修饰键。
我正在使用 Fastlane 在本地构建一个 iOS 应用程序,没有任何问题。
我正在使用match一个单独的 repo,以跟踪证书和配置文件。
在本地它工作正常。
但是,在 Bitrise 上,我收到此错误:
[05:23:16]:安装了所有必需的密钥、证书和配置文件
[05:23:16]:将配置文件类型设置为“应用商店”
[05:23:16]: ---------------
[05:23:16]:---步骤:build_app---
[05:23:16]: ---------------
[05:23:16]: $ xcodebuild -list -workspace Myapp.xcworkspace -configuration 调试
[05:23:17]: $ xcodebuild -showBuildSettings -workspace Myapp.xcworkspace -scheme Myapp -configuration Debug
[05:23:20]:无法自动检测配置文件映射
[05:23:20]:从 Xcode 9 开始,您需要提供什么的显式映射
[05:23:20]:配置文件以用于您应用的每个目标
[05:23:20]:没有那个文件或目录@rb_sysopen - /Users/vagrant/git/Pods/Target Support Files/Pods-Myapp/Pods-Myapp.debug.xcconfig
[05:23:20]:检测到配置文件映射:{:"com.myapp.myapp"=>"match AppStore com.myapp.myapp"}
我尝试明确映射我的配置文件Fastfile:
[05:23:16]: All required keys, certificates and provisioning profiles are installed [05:23:16]: Setting Provisioning Profile type to 'app-store' [05:23:16]: ----------------------- [05:23:16]: --- Step: build_app --- [05:23:16]: …
ios ×5
swift ×4
swiftui ×3
xcode ×3
auto-build ×1
bitrise ×1
cncontact ×1
fastlane ×1
localization ×1
modifier-key ×1
objective-c ×1
php ×1
shadow ×1
shift ×1
stack ×1
uikeyboard ×1
uitextview ×1
xcode10 ×1
yii2 ×1