English 中文(简体)
无法找到如何将图像装入 UIScrollView 的图像
原标题:Unable to figure out how to load images into a UIScrollView

我尝试将图像装入 UIScrollView 时遇到一个问题, 我不知道问题是否还存在于代码中, 或者在 Xcode 保留已删除图像的趋势中。 我尝试了所有可能的选项 :

  1. Delete and add again.
  2. Delete cache with Clean option
  3. Restore iphone simulator cache

但我不确定问题是否在我的代码里:

fotosJugadores = [[NSArray alloc] initWithObjects:@"cara5.png", @"cara7.png",
     @"cara8.png", @"cara9.png", @"cara11.png", @"cara13.png", @"cara14.png", 
     @"cara15.png", @"cara18.png",@"cara19.png", @"cara20.png", 
     @"cara32.png",@"cara44.png",@"cara51.png", @"cara100.png", @"cara101.png", 
     @"cara102.png",@"cara103.png", @"cara104.png", 
     @"cara105.png",@"cara106.png",@"cara107.png", nil];

numberOfViews = [fotosJugadores count];

for (int i = 0; i <    [fotosJugadores count]; i++) {

    UIImage *myImage = [UIImage imageNamed:[fotosJugadores objectAtIndex:i]];
    CGFloat yOrigin = i * myImage.size.width + 120;
    NSLog(@"my image %@", myImage);

    UIImageView *awesomeView = [[UIImageView alloc] initWithFrame:CGRectMake(yOrigin, 0, myImage.size.width, myImage.size.height)];
    awesomeView.tag = i;
    awesomeView.image = myImage;
    awesomeView.alpha = 0.5f;
    awesomeView.backgroundColor = [UIColor blackColor];
    [self.jugadorSlide addSubview:awesomeView];
    awesomeView=nil;

}

EDITED:这是对项目文件系统的屏幕拍摄, 图像以Expular/GBC/caras形式储存:

""https://i.sstatic.net/6SpFD.png" alt="此处的内置图像描述"/"

最佳回答

您的屏幕截图似乎显示您添加了“ caras” 文件夹作为引用。 如果您将文件夹添加为引用, 那么程序包中的文件路径将会是“ 文件夹名/ 文件名 ”, 而不是“ 文件名 ” 。

尝试使用

NSString *imagePath = [NSString stringWithFormat:@"Caras/%@", [fotosJugadores objectAtIndex:i]];
UIImage *myImage = [UIImage imageNamed:imagePath];
问题回答

检查您的文件名和扩展名的大小写。 还要确保您的 png 格式。 约32 位 png 不支持 。

您的超赞视频是否显示 和大小正确?





相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签