gpt4 book ai didi

ios - UIActivityIndi​​catorView startAnimating 在 searchBarSearchButtonClicked 中不起作用

转载 作者:行者123 更新时间:2023-11-29 02:29:25 27 4
gpt4 key购买 nike

我无法解决的问题是,当我执行时,我的 View 中的 UIActivityIndi​​catorView 不会开始动画

[UIActivityIndicatorView startAnimating];

searchBarSearchButtonClicked

这是我的代码:

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
[searchBar resignFirstResponder];

NSString *causeStr = nil;

if ([CLLocationManager locationServicesEnabled] == NO)
{
causeStr = @"device";
}
else if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied)
{
causeStr = @"app";
}
else
{
[_activityIndicatorView startAnimating];

_searchPlacesResults = [[NSMutableArray alloc] init];

NSString * searchQuery = [searchBar text];

FTGooglePlacesAPINearbySearchRequest *request = [[FTGooglePlacesAPINearbySearchRequest alloc] initWithLocationCoordinate:locationManager.location.coordinate];
request.rankBy = FTGooglePlacesAPIRequestParamRankByDistance;
request.keyword = searchQuery;
request.radius = 500;
[self startSearchingPlaces:request];
}

if (causeStr != nil)
{
NSString *alertMessage = [NSString stringWithFormat:@"You currently have location services disabled for this %@. Please refer to \"Settings\" app to turn on Location Services.", causeStr];

[[[UIAlertView alloc] initWithTitle:@"Location Services Disabled"
message:alertMessage
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil] show];
}
}

在我使用取消按钮清除连接到 UISearchBar 的 tableView 中的搜索结果之前,什么也不会发生。

我已经尝试并验证了

[UIActivityIndicatorView startAnimating];

从其他方法调用时实际上有效。

编辑:我还验证了我的 UIActivityIndi​​catorView 不为空,事实上这是我在 NSLog 时得到的结果:

<UIActivityIndicatorView: 0x16e91ed0; frame = (150 274; 20 20); hidden = YES; opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x16e91f90>>

最佳答案

您可以使用 SVProgresshood ,这是一个著名的事件指示器类。从here下载

SVProgressHUD 文件夹复制到您的项目。

#import "SVProgressHUD.h"

到您需要的 ViewController。

从哪里开始 Animate Activity indicator write :

[SVProgressHUD showWithStatus:@"Loading.."];

以及停止事件指示器的位置,写:

[SVProgressHUD dismiss];

您可以设置自己的状态而不是“正在加载..”

希望它有用。

关于ios - UIActivityIndi​​catorView startAnimating 在 searchBarSearchButtonClicked 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27093434/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com