[英]How show an full screen image in a seperate viewcontrller from a small image in webviewer (like facebook)?
HI stackoverflow的朋友
我在iphone中有一個Web應用程序,其中從Web服務器的Web視圖中加載了許多小圖像,當我單擊該圖像時,該圖像將在帶有導航之類的新ViewController中打開,如Facebook。 我怎樣才能做到這一點? 給我一些想法和一些示例代碼。
任何幫助將是可觀的。
首先將圖像放在html(php)中,如下所示:
echo "<a class='yourButton' href='inapp://".$image."'><img src="image.png"></a>";
其中$image
= $image
路徑。
然后在webView shouldStartLoadWithRequest
以下內容:
if ([request.URL.scheme isEqualToString:@"inapp"]) {
NSString *fullUrl=[NSString stringWithFormat:@"http://DOMAIN.com/%@",request.URL.host];
NSURL *imgpath = [[NSURL alloc] initWithString:fullUrl];
return NO;
}
因此,上面將返回imgpath
,它是用戶單擊圖像時的圖像的完整URL。 之后,您將必須加載一個新的內部帶有imageview的viewcontroller,然后使用AFNetworking( http://cocoadocs.org/docsets/AFNetworking/1.3.1/ )下載該圖像,並將該圖像加載到imageview中:
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 100.0f)];
[imageView setImageWithURL:[NSURL URLWithString:@"http://i.imgur.com/r4uwx.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder-avatar"]];
以上所有內容都寫在內存中,因此請適當調整代碼。我正在實施確切的解決方案,我將發布完整的工作代碼。 順便說一句,這可能是我在Stack中接受的第一個答案!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.