1
您能幫我瞭解,如何使用UIActivityIndicatorView+AFNetworking
或UIProgressView+AFNetworking
。我是否需要再創建一個UIViewController
,如果是,我需要在哪裏實施?發現我需要使用setProgressWithUploadProgressOfOperation
或setAnimatingWithStateOfOperation
,但我仍然需要一個示例。UIActivityIndicatorView + AFNetworking或UIProgressView + AFNetworking
我的代碼是:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
[manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[manager.requestSerializer setValue:@"" forHTTPHeaderField:@""];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
[manager GET:@"blablabla" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
// 3
//[self.view setAnimatingWithStateOfOperation:operation];
NSLog(@"JSON: %@", responseObject);
NSArray *carsList = responseObject[@"data"];
[self showStream:carsList];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
// 4
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertView show];
}];
indicatorView沒有顯示, – lhawks 2014-09-30 07:30:36
THX,我添加與框架初始化,一切都很好 – lhawks 2014-09-30 08:27:36