我创建了一个页面,我需要在同一页面中使用两个API,但我不知道如何在同一页面中为另一个URL调用另一个API。我在下面发布了我的代码。我已经使用API在集合视图中显示图像,现在另一个需要在滚动视图中使用,最多显示18个图像,最小值为零。我在下面发布我的代码用于第一个API调用 -
NSURL *url = [NSURL URLWithString:@"http://tattoosingles.net/webservice/tattoosingles.php"];
NSMutableURLRequest *request =[[NSMutableURLRequest alloc] initWithURL:
url];
NSString *postData = [[NSString alloc] initWithFormat:@"id=578&call=0"];
[request setCachePolicy:NSURLRequestUseProtocolCachePolicy];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/x-www-form-urlencoded; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:[postData dataUsingEncoding:NSUTF8StringEncoding]];
_connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
- (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse *)response
{
NSLog(@"Did Receive Response %@", response);
_responseData = [[NSMutableData alloc]init];
}
- (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data
{
//NSLog(@"Did Receive Data %@", data);
//NSLog(@"%@",data);
[_responseData appendData:data];
- (void)connection:(NSURLConnection*)connection didFailWithError: (NSError*)error
{
NSLog(@"Did Fail");
// [_activityView stopAnimating];
// _activityView.hidden=YES;
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@"Did Finish");
NSError * error = nil;
_responsedic = [NSJSONSerialization JSONObjectWithData:_responseData options:kNilOptions error:&error];
使用第一个API后,我的页面看起来像这样 -
另外一个API我必须用于上面的六边形图像。 请帮忙!!