工作,我无法打通的问题是,UIActivityIndicatorView在我看来,不启动动画当我执行UIActivityIndicatorView startAnimating不,在searchBarSearchButtonClicked
[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];
}
}
直到我清除搜索结果tableView使用其取消按钮连接到UISearchBar。
我曾尝试和验证其他方法调用时
[UIActivityIndicatorView startAnimating];
实际工作。
编辑: 我也已经验证了我的UIActivityIndicatorView不为空,其实这是我所得到的,当我的NSLog它:
<UIActivityIndicatorView: 0x16e91ed0; frame = (150 274; 20 20); hidden = YES; opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x16e91f90>>
你检查过else块包含的代码[UIActivityIndicatorView startAnimating]执行?你的NSLog显示UIActivityIndicatorView是隐藏的(hidden = YES);? – russell 2014-11-24 05:13:03
是的,我刚刚检查过,其他块正在执行。 – rambodrahmani 2014-11-24 10:05:42
由于_activityIndicatorView.hidesWhenStopped = YES,它显示HIDDEN; – rambodrahmani 2014-11-24 10:06:16