我很抱歉,因为这可能是一个愚蠢的noob问题......
我正在使用SDWebImage在我的cellForRowAtIndexPath方法中的UITableView中显示图片,使用经典
[cell.pointPicture setImageWithURL:[NSURL URLWithString:thePoint.imageURL] placeholderImage:[UIImage imageNamed:POINT_DEFAULT_IMAGE]];
Run Code Online (Sandbox Code Playgroud)
(显示的图片很轻,压缩得很好jpgs,只是一些ko,是的,我当然正在使用dequeueReusableCellWithIdentifier).
当我用" Instrument - Allocations " 检查我的应用程序,然后向下滚动我的UITableView(包含40个包含图片的单元格,有点像Instagram),我使用了大量的内存!(见截图)

但它似乎是" VM ",尤其是来自coreGraphics库的" VM:CG栅格数据 ".
所以问题是:
对不起,但经过网上搜索后,我找不到任何有关" VM:CG栅格数据 "的相关信息......有什么想法吗?提前致谢 !
我正在使用Kingfisher来显示来自网址的图片,但我的端点需要一个授权标头.如何在iOS中使用Kingfisher或SDWebImage这些网址?
我正在开发一个iOS应用程序,它使用alamofire和swiftyJSON与API进行交互.在这个api中,我得到了一堆返回的值,其中一个是图像.返回的图像以数组的形式出现,但我能够遍历数组并显示单个图像.为了使应用程序更高级,我决定在我的应用程序中实现UIPageViewController类.我调用了API函数并试图将我的图像传递给视图控制器.
我的故事板中的事物列表
据我所知,我的代码很好,但是当我运行应用程序时,控制台中没有任何反应.以下是我的代码.
protocol ProductImagesPageViewControllerDelegate: class {
func setupPageController(numberOfPages: Int)
func turnPageController(to index: Int)
}
class ProductPageVC: UIPageViewController {
weak var pageViewControllerDelegate: ProductImagesPageViewControllerDelegate?
override func viewDidLoad() {
super.viewDidLoad()
automaticallyAdjustsScrollViewInsets = false
dataSource = self
delegate = self
}
func configureImg() {
let productId = ProductServices.instance.selectedProduct?.id
ProductServices.instance.findIndividualProducts(id: productId!, completion: { (success) in
if success {
ProductServices.instance.productDetails.forEach({ (productDetail) in
let images = productDetail.productImg.count
if images > 0 {
for image in 0..<(images) {
let imageVC = self.storyboard?.instantiateViewController(withIdentifier: PRODUCT_IMAGE_VC) …Run Code Online (Sandbox Code Playgroud) 我正在使用 Xcode 13.0 (13A233) 在配备 M1 芯片的 Macbook 上开发一个应用程序。将 pod 更新到最新版本后,pod 抱怨错误
CompileSwiftSources 正常的arm64 com.apple.xcode.tools.swift.compiler(在项目“Pods”的目标“Alamofire”中)
并且不为真实设备或模拟器构建。
我在项目中包含以下 pod:
我已经为主项目和所有 pod 项目应用了以下解决方案:
您可以在此屏幕截图上查看错误详细信息。
我知道与这些问题相关的答案有很多,但我已经尝试了每个问题,当我无法用这些答案解决问题时,我在这里发布问题。
我正在使用SDWebImage和抓取与新闻API中的新闻文章相关联的图像.
问题是,在我开始滚动之前,屏幕上的单元格图像没有加载UITableView.一旦我滚过一个单元格,它就会离开屏幕,一旦我回到它,最终会加载Image.
这是我的(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath代码:
if ([feedLocal.images count] == 0) {
[cell.imageView setImage:[UIImage imageNamed:@"e.png"]];
}
else {
Images *imageLocal = [feedLocal.images objectAtIndex:0];
NSString *imageURL = [NSString stringWithFormat:@"%@", imageLocal.url];
NSLog(@"img url: %@", imageURL);
// Here we use the new provided setImageWithURL: method to load the web image
__weak UITableViewCell *wcell = cell;
[cell.imageView setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", imageURL]]
placeholderImage:[UIImage imageNamed:@"115_64.png"]
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
if(image == nil) {
[wcell.imageView setImage:[UIImage …Run Code Online (Sandbox Code Playgroud) 我已成功使用SDWebImage很长时间了.但是当我们设置图像时,iOS8会崩溃
[ myImageView setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",@"url"]] placeholderImage:[UIImage imageNamed:PROFILE_HOLDER_IMAGE]];
Run Code Online (Sandbox Code Playgroud)
有没有办法避免它
干杯
我需要在我的应用程序中管理照片,并阅读了很多关于SDWebImage框架的内容,这似乎是最好的方法.但是我发现它非常难以安装.我不知道Ruby并且从未使用过podfile,所以我通过下载最新的SDWebImage文件夹和框架并将它们添加到我的项目来安装它.但是当我尝试使用建议的导入导入到我的viewcontroller时:
#import <SDWebImage/UIImageView+WebCache.h>
#import "UIImageView+WebCache.h"
Run Code Online (Sandbox Code Playgroud)
我在#import上找到了一个未找到的文件然后如果我将其更改为"SDWebImage/UIImageView + WebCache.h",建议我在#import UIImageView + WebCache.h上找不到文件,即使我可以清楚地看到当我在项目中打开SDWebImage文件夹时!我猜这些错误在我尝试使用sd_setImageWithUrl方法时也会导致找不到错误.
这是我的项目的屏幕截图:
我希望我可以得到一些帮助,因为框架看起来具有非常好的功能.任何帮助非常感谢.谢谢
这是我的简单扩展UIImageView:
extension UIImageView {
func setImageWithUrl(url: String?) {
setImageWithUrl(url, placeholder: nil)
}
private func setImageWithUrl(url: String?, placeholder: UIImage? = UIImage(), deleteCacheImage: Bool = false) {
image = placeholder ?? image
if let url = url {
let activityIndicatorView = UIActivityIndicatorView(frame: CGRectMake(0, 0, CGRectGetWidth(frame), CGRectGetHeight(frame)))
activityIndicatorView.hidden = false
activityIndicatorView.color = UIColor.curiousBlue()
addSubview(activityIndicatorView)
bringSubviewToFront(activityIndicatorView)
activityIndicatorView.startAnimating()
let options = deleteCacheImage ? SDWebImageOptions.RefreshCached : SDWebImageOptions.LowPriority
sd_setImageWithURL(NSURL(string: url), placeholderImage: placeholder, options: options, completed: { image, error, cache, url in
activityIndicatorView.hidden = true
activityIndicatorView.stopAnimating() …Run Code Online (Sandbox Code Playgroud) 这是非常奇怪sd_setImageWithURL的工作,但在sd_setShowActivityIndicatorView:YES和中得到一个错误sd_setIndicatorStyle.
低于我所做的.
[cell.cellImgView sd_setShowActivityIndicatorView:YES];
[cell.cellImgView sd_setIndicatorStyle:UIActivityIndicatorViewStyleGray];
[cell.cellImgView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://img.youtube.com/vi/%@/hqdefault.jpg",[[[galleryDic objectForKey:@"data"] valueForKey:@"Video_id"] objectAtIndex:indexPath.row]]] placeholderImage:[UIImage imageNamed:@"youtube-video"] ];
Run Code Online (Sandbox Code Playgroud)
我正在尝试剪切图像,正如我们看到的 UI 一样,它看起来不错,但实际上它不会剪切图像,从而导致其他 UI 元素无响应。
这是我正在使用的代码。
struct ImageContentView: View {
var urls:[String] = [
"https://lh3.googleusercontent.com/proxy/80im-IBfLODpLDj8d02uEpSVIhqdjen6H6CeFwgRBxeua-Dgw0R3WONFj1Gk8CwB_MufmC9rQ8qHjyWMejwFcJ1PA2s8AAu5WVsmJA=s0-d",
"https://wallpaperaccess.com/full/530919.jpg"
]
var body: some View {
ScrollView{
VStack{
Button(action: {
}, label: {
Text("Hello")
})
VStack(spacing: 20.0) {
ForEach(self.urls, id:\.self) { url in
WebImage(url: URL.init(string: url)!)
.resizable()
.aspectRatio(contentMode: ContentMode.fill)
.frame(height: UIScreen.main.bounds.size.width * 0.5)
.clipped()
.cornerRadius(10.0)
.shadow(color: Color.red, radius: 10.0, x: 0, y: 0)
}
}.padding()
}
}
}
}
Run Code Online (Sandbox Code Playgroud) sdwebimage ×10
ios ×8
objective-c ×3
swift ×3
alamofire ×2
uiimageview ×2
uitableview ×2
clipped ×1
frameworks ×1
imageview ×1
ios8 ×1
json ×1
kingfisher ×1
memory-leaks ×1
swiftui ×1
xcode ×1
xcode11 ×1
xcode13 ×1