我尝试在swift上创建我的搜索栏,但是当我按下搜索栏时,我有一个问题就是在屏幕上关闭键盘.当我尝试使用textfield时,它可以很好地使用此代码.
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
self.view.endEditing(true)
}
Run Code Online (Sandbox Code Playgroud)
当我按下我的文本字段然后键盘消失时,它工作.我想用我的搜索栏制作这样的东西,因为当我使用搜索栏并使用与textfield相同的方式时,它根本不起作用.任何参考或代码对我都非常有用.
从Xcode 5升级到6,现在我的搜索栏色调为黑色.
试图通过故事板右侧窗格>"Bar Tint"更改它以清除颜色,但它仍然是黑色.
也以编程方式尝试:
[self.searchBar setTintColor:[UIColor clearColor]];
Run Code Online (Sandbox Code Playgroud)
还是黑的:(
有任何想法吗?
我用谷歌API和IGN API(法语地图)开发自己的地图,我想添加一个谷歌地图搜索框,但即使仔细阅读谷歌地图API,也无法找到成功的方法.
这就是我所拥有的:http: //www.tiphainebuccino.com/site/Map/LaCarteAuxTresors_2.html
这就是我要添加的内容(不会丢失我的实际设置):https://developers.google.com/maps/documentation/javascript/examples/places-searchbox?我 = fr
我不明白如何混合两个HTML代码.有人可以帮帮我吗?我在html + javascript工作,而且我是初学者:)
谢谢
Tiphaine
相关(非工作)代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>La Tarte Aux Crésors "Beta"</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
"use strict";
var ignKey = "ljozkgwvms60dtumhx67z6u3"
function makeIGNMapType(layer, name, maxZoom) {
return new google.maps.ImageMapType({
getTileUrl: function(coord, zoom) {
return "http://gpp3-wxs.ign.fr/" + ignKey + "/geoportail/wmts?LAYER=" +
layer +
"&EXCEPTIONS=text/xml&FORMAT=image/jpeg&SERVICE=WMTS&VERSION=1.0.0" +
"&REQUEST=GetTile&STYLE=normal&TILEMATRIXSET=PM&TILEMATRIX=" +
zoom + "&TILEROW=" + coord.y + "&TILECOL=" + coord.x;
}, …
Run Code Online (Sandbox Code Playgroud) 我正在iOS 6和iOS 7之间进行UI转换.
我们有一个与UISearchDisplayController相关的UISearchBar,我已经将navigationBar的backgroundImage和searchBar设置为用颜色动态创建的1x1图像.
self.searchDisplayController.searchBar.translucent = NO;
self.searchDisplayController.searchBar.barTintColor = [UIColor clearColor];
self.searchDisplayController.searchBar.tintColor = [UIColor myTintColor];
self.searchDisplayController.searchBar.backgroundImage = [self imageWithColor:[UIColor myBGColor]];
self.searchDisplayController.searchBar.scopeBarBackgroundImage = [self imageWithColor:[UIColor myBGColor]];
Run Code Online (Sandbox Code Playgroud)
在iOS6上,一切都按预期工作.在iOS7上,当选择了searchBar时,scopeBar会出现好的backgroundImage(使用searchBar.scopeBarBackgroundImage设置),但searchBar是一种半透明的灰色.当我按下取消时,searchBar backgroundImage又回来了.
////////////////////////////////////////////////// ////////////////////////////////////////////////// /
编辑问题
////////////////////////////////////////////////// ////////////////////////////////////////////////// /
实际上,我确实在这里和那里使用了barTintColor和其他选项,但它不起作用.这是barTintColor设置为相同颜色的结果.但是顶部有这个白色层
我试图谷歌它,并惊奇地发现没有结果相关...我想知道如何使用CSS调整搜索框内的CSS闪烁光标?我调整了搜索框的大小,但似乎闪烁的光标大小仍然是原始的小文本大小.
我想知道谷歌使用什么算法使Chrome浏览器的地址栏充当SO,Quroa等许多网站的默认搜索栏,但不适用于facebook,metastackoverflow等.
例如,如果要在stackoverflow中搜索主题,可以在chorme中执行此操作.
搜索结果将直接带您进入stackoverflow页面.即
如果您选择quora.com
在chrome的地址栏中进行搜索,也会发生同样的情况.但是,如果您facebook.com
在地址栏和许多其他具有搜索栏的网站中进行搜索,则不会发生这种情况.
这是怎么回事?谷歌使用什么算法来实现这一目标?
希望我对我的问题很清楚?任何帮助,将不胜感激.
有很多教程,但不是帮助我继续前进,而是迷失在所有可能的选项中,或者我不知道如何改进代码(我想使用一个应用程序,该应用程序显示的列表不仅仅使用三个水果或三个城市的名字?)
我找到了创建一个漂亮的 SearchBar 的教程,它能够根据输入的第一个字母显示结果。
我不明白如何使用包含与内容相关联的标题的数据列表来编辑教程。如果第一个字母是小写或大写,我不明白如何显示结果。有没有可能帮我写一个简单的基础代码,可以为所有人服务,包括像我这样的初学者?
数据列表.dart
List<ListWords> listWords = [
ListWords('oneWord', 'OneWord definition'),
ListWords('twoWord', 'TwoWord definition.'),
ListWords('TreeWord', 'TreeWord definition'),
];
class ListWords {
String titlelist;
String definitionlist;
ListWords(String titlelist, String definitionlist) {
this.titlelist = titlelist;
this.definitionlist = definitionlist;
}
}
Run Code Online (Sandbox Code Playgroud)
Searchbar.dart
import 'package:flutter/material.dart';
import 'package:test_searchbar/DataList.dart';
class SearchBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Search App'),
actions: <Widget>[
IconButton(icon: Icon(Icons.search),
onPressed: () {
showSearch(context: context, delegate: DataSearch(listWords));
})
],
),
drawer: Drawer(),
);
} …
Run Code Online (Sandbox Code Playgroud) 在xcode 9中,当我将搜索栏放在视图中时,它会自动移动UI的其余部分.当我尝试从视图中删除搜索栏时,我得到一个黑色空间而不是正在更正的UI.我使用的是:self.navigationItem.searchController = nil.我尝试了很多东西,但是在删除搜索栏后我不知道如何更正UI.只有当我移动到另一个视图控制器并且在没有搜索栏的情况下再次返回UI是正确的.我在这里错过了什么?
码:
@IBAction func searchIconPressed(_ sender: UIBarButtonItem) {
//ios 11
if #available(iOS 11.0, *) {
if self.navigationItem.searchController == nil {
self.navigationItem.searchController = self.searchController
self.searchController.isActive = true
}
else {
self.navigationItem.searchController?.isActive = false
self.navigationItem.searchController = nil
}
}
//when ios 9-10
else {
if self.navigationItem.titleView == nil {
self.navigationItem.titleView = self.searchController.searchBar
self.searchController.isActive = true
}
else {
self.navigationItem.titleView = nil
}
}
}
Run Code Online (Sandbox Code Playgroud)
}
单击搜索或单击取消时键盘隐藏.但是我也希望当我点击屏幕上的某个地方时键盘会隐藏.我找到了几个文本教程,但我们正在使用搜索栏.
谁能告诉我怎么做?
谢谢.
我已经在SO上阅读了类似的问题和解决方案.但似乎没有一个能解决我的问题.我正在使用自定义搜索控制器和自定义搜索栏,并且没有调用func updateSearchResults(对于searchController:UISearchController).
var customSearchController: CustomSearchViewController!
Run Code Online (Sandbox Code Playgroud)
CustomSearchViewController:在ViewDidLoad()中
customSearchController = CustomSearchViewController(searchResultsController: ***nil***, searchBarFrame: CGRect(x: 0.0, y: 0.0, width: searchTableView.frame.size.width, height: 44.0), searchBarFont: UIFont(name: "HelveticaNeue", size: 16.0)!, searchBarTextColor: UIColor.purple, searchBarTintColor: UIColor.white)
customSearchController.searchResultsUpdater = self
customSearchController.definesPresentationContext = true
customSearchController.customSearchBar.placeholder = "What are you looking for?"
customSearchController.customSearchBar.backgroundColor = UIColor.white
customSearchController.customSearchBar.sizeToFit()
customSearchController.customSearchBar.resignFirstResponder()
customSearchController.customSearchBar.showsCancelButton = true
customSearchController.customSearchBar.delegate = self
Run Code Online (Sandbox Code Playgroud)
没有被召唤::(
func updateSearchResults(for searchController: UISearchController) {
filtered.removeAll()
filtered = searchArray.filter({ (text) -> Bool in
let tmp: NSString = text as NSString
let range = tmp.range(of: customSearchController.customSearchBar.text!, …
Run Code Online (Sandbox Code Playgroud) searchbar ×10
ios ×3
keyboard ×2
uisearchbar ×2
address-bar ×1
css3 ×1
dart ×1
flutter ×1
google-maps ×1
hide ×1
html ×1
ios11 ×1
ios7 ×1
ios8 ×1
iphone ×1
javascript ×1
search ×1
swift ×1
transition ×1
uikit ×1
xcode9 ×1