我在 ios 中使用 Google 自动完成 placekicker。它向我展示了具有本机设计的控制器。我想自定义它的导航栏颜色。但我无法做到。下面是代码
let autocompleteController = GMSAutocompleteViewController()
autocompleteController.tintColor = UIColor.red
autocompleteController.navigationController?.navigationBar.barTintColor = Constant.AppColor.navigationColor
autocompleteController.delegate = self
self.present(autocompleteController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
我有一个显示项目的 UICollection 视图。现在我想在 UICollectionView 上添加分页。我不想为此功能使用任何第三方。请让我知道我如何实现这一目标!
我有四个一个例子http://slicode.com/bottom-refresh-control-uicollectionview/
但是在此我必须将滚动视图向上拖动几秒钟才能使其工作。
我正在尝试从我的机器在其他机器上的docker上执行命令。当我执行此命令时:
- name: Add header
command: docker exec cli bash -l -c "echo '{"payload":{"header":{"channel_header":{"channel_id":"gll", "type":2}},"data":{"config_update":'$(cat jaguar_update.json)'}}}' | jq . > jaguar_update_in_envelope.json"
Run Code Online (Sandbox Code Playgroud)
通过ansible剧本,我得到下面显示的错误。
fatal:[
command-task
]:FAILED! =>{
"changed":true,
"cmd":[ ],
"delta":"0:00:00.131115",
"end":"2019-07-11 17:32:44.651504",
"msg":"non-zero return code",
"rc":4,
"start":"2019-07-11 17:32:44.520389",
"stderr":"mesg: ttyname
failed: Inappropriate ioctl for device\nparse error: Invalid numeric
literal at line 1, column 9",
"stderr_lines":[
"mesg: ttyname failed:
Inappropriate ioctl for device",
"parse error: Invalid numeric literal
at line 1, column 9"
],
"stdout":"",
"stdout_lines":[
]
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我在docker容器中手动执行命令,它可以正常工作,而且我没有任何问题。
编辑:如建议,我尝试与shell …
我有两个视图控制器A和B.在ViewController A我正在显示来自服务器的数据.我有导航按钮更新转到ViewController B.在B我可以更新ViewController B上显示的数据.现在当服务器上的数据更新时显示单击"确定"后出现"更新成功"警报我转到上一页ViewController.但是我没有看到更新的数据,因为我从堆栈中删除了ViewController B但是A没有被重新启动.
返回ViewController的代码A.
[self.navigationController popViewControllerAnimated:YES];
Run Code Online (Sandbox Code Playgroud) Helo all,
我在这里有一个非常奇怪的情况.我有一个表格视图,其中我有自定义单元格.所以我设计了自己的自定义单元格.在自定义单元格中我也显示图像以及文本.表格的数据来自服务器.如果json中有任何图像,则显示图像,否则只显示文本.因此单元格将是动态的.我已经习惯bezier path在图像周围包装文字.如果图像在那里,那么文字将被包装.当我从服务器添加新帖子与图像&我刷新表格然后它自动显示其他帖子的图像.它将显示相同的图像是最后一个相同的图像.我不知道为什么新的单元格在它的单元格中添加图像,即使代码工作正常,我已经使用断点对其进行了dbug.请告诉可能是什么问题.
这是代码 cellForRowAtIndexPath
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//define variables here
static NSString *CellIdentifier = @"homeCell";
HomeCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier
forIndexPath:indexPath];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
if([arr_post count]>0)
{
NSMutableAttributedString *mutableAttributeStr;
NSAttributedString *attributeStr;
[cell layoutIfNeeded];
//get the post data
Post *user_post=[arr_post objectAtIndex:indexPath.row];
//set the button tags
cell.btn_like.tag=indexPath.row;
cell.btn_comment.tag=indexPath.row;
cell.btn_fav.tag=indexPath.row;
cell.btn_con.tag=indexPath.row;
cell.btn_book.tag=indexPath.row;
//add info to buttons
cell.btn_like.selected=user_post.isPostLiked;
cell.btn_comment.selected=user_post.isPostCommented;
cell.btn_fav.selected=user_post.isPostFavourite;
cell.btn_con.selected=user_post.isPostCondolence;
cell.btn_book.selected=user_post.isPostBookmarked;
//add user info
cell.label_name.text=user_post.username;
cell.img_profile.layer.cornerRadius = 25;
cell.img_profile.clipsToBounds = YES;
[cell.img_profile setImageWithURL:[NSURL URLWithString:[IMAGE_BASE_URL stringByAppendingString:user_post.user_profileImage]]placeholderImage:[UIImage imageNamed:@"post_placeholder.png"]]; …Run Code Online (Sandbox Code Playgroud) 我在swift中创建了一个自定义导航抽屉.我使用了app delegate中的窗口并添加了关于挡风玻璃的视图.我隐藏后显示按钮单击视图.
下面的代码创建抽屉.
func setupSideMenu(){
windowSideMenu = ((UIApplication.shared.delegate?.window)!)!
windowSideMenu.backgroundColor = UIColor.black
if customView == nil {
print("custom view nil")
// Register Swipe gesture for opening slideMenu
let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(self.openSideMenu))
swipeRight.direction = UISwipeGestureRecognizerDirection.right
self.view.addGestureRecognizer(swipeRight)
/// Register Drawable NIB here only for once
customView = SideView.instanceFromNib() as! SideView
customView.configureDrawer()
customView.navigationController = self.navigationController
customView.frame = CGRect(x: -customView.frame.size.width, y: -10, width: self.view.bounds.size.width - 30, height:UIScreen.main.bounds.height)
customView.drawerDelegate = self
/// BackView (DimView)
backView.frame = self.view.frame
backView.backgroundColor = UIColor.black
backView.alpha = 0.4 …Run Code Online (Sandbox Code Playgroud) 我有我的屏幕层次结构.
-ScrollView
-ContentView
-View1
-View2
-View3
-Collectioview
-CollectioviewCell
-Tableview
-Tableviewcell
-Content
Run Code Online (Sandbox Code Playgroud)
现在这里我的tableview内容是动态的,因此tableview单元格的高度不能是静态的.所以tableview的高度将根据每个单元格的单元格数和高度而增加.
基于Tableview高度,集合视图的高度应该增加,这导致滚动视图内容视图的高度增加.
但我无法理解如何用更少的代码实现这一目标?或者可以以编程方式完成?
我通过从左到右预先设置一个带有自定义动画的控制器来创建一个演示导航抽屉.当我们关闭控制器时,我们从右到左应用动画.它虽然有效,但抽屉动画看起来不像原生的android抽屉那么好.所以你能告诉我实现这一目标的最佳方法是什么.虽然我不想依赖任何第三方来实现此功能.
@IBAction func actionMenu(_ sender: Any) {
let controler:DrawerController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "DrawerController")
as! DrawerController
let transition = CATransition()
transition.duration = 0.5
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromLeft
transition.timingFunction = CAMediaTimingFunction(name:kCAMediaTimingFunctionDefault)
view.window!.layer.add(transition, forKey: kCATransition)
present(controler, animated: false) {
controler.drawerView.backgroundColor = UIColor.black
controler.drawerView.alpha = 0.6
}
}
Run Code Online (Sandbox Code Playgroud)
我正在编写一个 shell 脚本,其中通过终端在 Mac 上安装 docker。我能够通过安装brew cask install docker。现在它是基于 GUI 的 docker,等待用户事件继续。现在,在我的 shell 脚本中,我想保持执行,直到 docker 启动并运行。我找到了一个很好的脚本来检查 docker 是否正在运行。我可以按如下方式检查它。
#!/bin/bash
rep=$(curl -s --unix-socket /var/run/docker.sock http://ping > /dev/null)
status=$?
if [ "$status" == "7" ]; then
echo 'not connected'
exit 1
fi
echo 'connected'
exit 0
Run Code Online (Sandbox Code Playgroud)
我尝试将其放入一个循环中,以便在状态为 0 之前它应该一次又一次地检查并保留异常。我没有 shell 脚本编写经验,但尝试了一种运行方法但失败了。我怎样才能做到这一点。
我的剧本
#!/bin/bash
status=0
test() {
rep=$(curl -s --unix-socket /var/run/docker.sock http://ping > /dev/null)
status=$?
}
checkDocker() {
while [ "$status" == "7" ]
do
echo waiting docker to start
test …Run Code Online (Sandbox Code Playgroud) 我创建了一个docker-compose文件,该文件具有Go和的两个服务Mysql。它为go和mysql创建容器。现在我正在运行尝试连接到作为docker容器运行的mysql数据库的代码。但我得到错误。
docker-compose.yml
version: "2"
services:
app:
container_name: golang
restart: always
build: .
ports:
- "49160:8800"
links:
- "mysql"
depends_on:
- "mysql"
mysql:
image: mysql
container_name: mysql
volumes:
- dbdata:/var/lib/mysql
restart: always
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=testDB
- MYSQL_USER=root
- MYSQL_PASSWORD=root
ports:
- "3307:3306"
volumes:
dbdata:
Run Code Online (Sandbox Code Playgroud)
连接到mysql数据库时出错
golang | 2019/02/28 11:33:05 dial tcp 127.0.0.1:3306: connect: connection refused
golang | 2019/02/28 11:33:05 http: panic serving 172.24.0.1:49066: dial tcp 127.0.0.1:3306: connect: connection refused
golang | goroutine 19 [running]:
Run Code Online (Sandbox Code Playgroud)
与MySql数据库的连接 …