「Ios/swift/外部ライブラリ/SDWebImage」の版間の差分
ナビゲーションに移動
検索に移動
編集の要約なし |
|||
| (同じ利用者による、間の3版が非表示) | |||
| 5行目: | 5行目: | ||
==インストール== | ==インストール== | ||
vi Podfile | $ vi Podfile | ||
platform :ios, '9.0' | platform :ios, '9.0' | ||
target 'Helloworld' do | target 'Helloworld' do | ||
| 22行目: | 22行目: | ||
imageView1.center = CGPointMake(200, 200) | imageView1.center = CGPointMake(200, 200) | ||
self.view.addSubview(imageView1) | self.view.addSubview(imageView1) | ||
==httpによるアクセス== | |||
ios9ではhttpだと取得できない。httpsであればok | |||
参考:http://mushikago.com/i/?p=6150 | |||
==ios9以降でhttpのアクセスを許可する== | |||
httpによるアクセスは推奨はされていないが・・ | |||
info.plistを選択しOpen_As/Source_Fileを選択し以下を追加 | |||
<key>NSAppTransportSecurity</key> | |||
<dict> | |||
<key>NSAllowsArbitraryLoads</key> | |||
<true/> | |||
</dict> | |||
2016年6月22日 (水) 19:54時点における最新版
SDWebImageとは
外部画像取得ライブラリ
非同期取得で、キャッシュ機能などがある。
インストール
$ vi Podfile platform :ios, '9.0' target 'Helloworld' do use_frameworks! pod 'SDWebImage', '~>3.6' end
$ pod install
swfit記述
import SDWebImage
let image1:UIImage? = UIImage(named:"loading.png")
let imageView1 = UIImageView(image:image1)
let imageURL = NSURL(string: "https://www.google.co.jp/logos/doodles/2016/first-day-of-summer-2016-northern-hemisphere-5669295896920064.2-hp.gif")
imageView1.sd_setImageWithURL(imageURL)
imageView1.center = CGPointMake(200, 200)
self.view.addSubview(imageView1)
httpによるアクセス
ios9ではhttpだと取得できない。httpsであればok
参考:http://mushikago.com/i/?p=6150
ios9以降でhttpのアクセスを許可する
httpによるアクセスは推奨はされていないが・・
info.plistを選択しOpen_As/Source_Fileを選択し以下を追加
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>