这个问题与 Flutter 有关。我在 TextField 上方有一个 DropdownButton,如下所示:
DropdownButton<String>(
isExpanded: true,
hint: Text(associatedHint),
disabledHint: Text(associatedHint),
items: diagnosesList.map((int value) {
return DropdownMenuItem<String>(
value: value.toString(),
child: Text(dxDisplay),
);
}).toList(),
value: ANID,
onChanged: (String newANID) {
setState(() {
ANID = newANID;
});
},
),
TextField(
autofocus: true,
keyboardType: keyboardType,
maxLines: maxLines,
textCapitalization: TextCapitalization.sentences,
controller: _textEntryController,
decoration: InputDecoration(hintText: "Entry"),
onChanged: (value) {
noteEntry = value;
},
),
Run Code Online (Sandbox Code Playgroud)
TextField 自动对焦会立即调出键盘。当您点击 DropdownButton 时,它会从 TextField 中移除焦点,从而关闭键盘。这会在屏幕上移动内容并造成糟糕的用户体验。
关于如何解决这个问题有什么建议吗?有没有办法即使在点击 DropdownButton 后也能保持键盘处于抬起状态?
我正在尝试使用Swift在iOS 11中使用新的大型标题系统。当标题过长时(请参见图像示例),它会添加...而不是换行或缩小文本大小。如何添加换行符?

这是我用来设置标题的一些代码:
self.navigationController?.navigationBar.prefersLargeTitles = true
self.navigationController?.navigationBar.largeTitleTextAttributes = [NSForegroundColorAttributeName: MyGlobalVariable.themeMainColor]
self.navigationController?.navigationBar.largeTitleTextAttributes = [NSFontAttributeName: UIFont.systemFont(ofSize: 22)]
navigationItem.title = "Search by Name"
Run Code Online (Sandbox Code Playgroud) 我有一些代码可以删除所有标点符号:
mysentence.components(separatedBy: .punctuationCharacters).joined().components(separatedBy: " ")
Run Code Online (Sandbox Code Playgroud)
现在,我尝试为破折号字符“-”添加例外。换句话说,我想删除除破折号之外的所有标点符号。
看起来在Java中这可以通过使用正则表达式的replaceall来完成(诚然我不知道如何使用)。我如何在 Swift 4 中做到这一点?