Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 向uisearchbar添加刷新徽标_Ios_Xcode_Ipad - Fatal编程技术网

Ios 向uisearchbar添加刷新徽标

Ios 向uisearchbar添加刷新徽标,ios,xcode,ipad,Ios,Xcode,Ipad,有没有可能在iPad的uisearchbar上添加像safari中那样的刷新徽标? 喜欢下面的图片吗 我有一个uisearchbarcontroller和一个uitableview。想知道是否可以像刷新一样添加箭头。可以添加搜索结果和书签 谢谢。是的,你可以。。您需要将清除按钮替换为自定义按钮,以执行刷新操作。。下面是实现这一点的代码 UISearchBar *searchBar = yourSearchBar; UITextField *searchtextfield = [searchBa

有没有可能在iPad的uisearchbar上添加像safari中那样的刷新徽标? 喜欢下面的图片吗

我有一个uisearchbarcontroller和一个uitableview。想知道是否可以像刷新一样添加箭头。可以添加搜索结果和书签


谢谢。

是的,你可以。。您需要将清除按钮替换为自定义按钮,以执行刷新操作。。下面是实现这一点的代码

UISearchBar *searchBar = yourSearchBar;
UITextField *searchtextfield = [searchBar.subviews objectAtIndex:1];
UIButton *cButton = [UIButton buttonWithType:UIButtonTypeCustom];
cButton.frame = CGRectMake(0, 0, 20 , 20);
cButton.backgroundColor = [UIColor clearColor];
[cButton setImage:[UIImage newImageFromResource:@"yourButtonImage"] forState:UIControlStateNormal];//refresh image.
cButton.contentMode = UIViewContentModeScaleToFill;
[cButton addTarget:self action:@selector(refreshButtonPressed) forControlEvents:UIControlEventTouchUpInside];//This is the custom event(refresh)
[searchtextfield setRightView:cButton];
[searchtextfield setRightViewMode:UITextFieldViewModeAlways];

享受:)

是的,你可以。。您需要将清除按钮替换为自定义按钮,以执行刷新操作。。下面是实现这一点的代码

UISearchBar *searchBar = yourSearchBar;
UITextField *searchtextfield = [searchBar.subviews objectAtIndex:1];
UIButton *cButton = [UIButton buttonWithType:UIButtonTypeCustom];
cButton.frame = CGRectMake(0, 0, 20 , 20);
cButton.backgroundColor = [UIColor clearColor];
[cButton setImage:[UIImage newImageFromResource:@"yourButtonImage"] forState:UIControlStateNormal];//refresh image.
cButton.contentMode = UIViewContentModeScaleToFill;
[cButton addTarget:self action:@selector(refreshButtonPressed) forControlEvents:UIControlEventTouchUpInside];//This is the custom event(refresh)
[searchtextfield setRightView:cButton];
[searchtextfield setRightViewMode:UITextFieldViewModeAlways];
享受:)

对于iOS 7,请更换:

UITextField *searchtextfield = [searchBar.subviews objectAtIndex:1];
与:

对于iOS 7,请替换:

UITextField *searchtextfield = [searchBar.subviews objectAtIndex:1];
与: