2011-08-24 24 views

回答

0

第一名像這樣在你的HTML(PHP)的圖像:

echo "<a class='yourButton' href='inapp://".$image."'><img src="image.png"></a>"; 

其中$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的裏面,下載與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"]]; 

以上所有都寫在內存中,以便調整自己的代碼我正在實施確切的解決方案,我將發佈完整的工作代碼。順便說一下,這可能是我第一次接受堆棧中的答案!

相關問題