以下是基於設備從flickr檢索圖像的示例代碼。在爲請求創建圖像網址時,請更改設備的圖像名稱。在這種情況下,它只是中等和中等大小的圖像。
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
photoURLString = [NSString stringWithFormat:@"http://farm%@.static.flickr.com/%@/%@_%@_m.jpg", [photo objectForKey:@"farm"], [photo objectForKey:@"server"], [photo objectForKey:@"id"], [photo objectForKey:@"secret"]];
}
else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
photoURLString = [NSString stringWithFormat:@"http://farm%@.static.flickr.com/%@/%@_%@_l.jpg", [photo objectForKey:@"farm"], [photo objectForKey:@"server"], [photo objectForKey:@"id"], [photo objectForKey:@"secret"]];
}
[self.photoURLsImage addObject:[NSData dataWithContentsOfURL:[NSURL URLWithString:photoURLString]]];
所以你會檢測到iPhone/iPad的屏幕大小,並將其作爲參數傳遞給Web服務? – user1904273 2014-10-27 03:22:28