IOS-图像不以编程方式显示
我在代码中设置了图像,但图像不显示。当我在iPhone或模拟器上运行时,图像不会显示 我会给你提供代码 以下是迄今为止的代码:IOS-图像不以编程方式显示,ios,objective-c,uiimageview,Ios,Objective C,Uiimageview,我在代码中设置了图像,但图像不显示。当我在iPhone或模拟器上运行时,图像不会显示 我会给你提供代码 以下是迄今为止的代码: @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor colorWithRed:70.0f/255.0f
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithRed:70.0f/255.0f
green:111.0f/255.0f
blue:162.0f/255.0f
alpha:1.0f];
UIView *viewTopBar = [[UIView alloc] init];
[self.view addSubview:viewTopBar];
viewTopBar.backgroundColor = [UIColor colorWithRed:53.0f/255.0f
green:85.0f/255.0f
blue:127.0f/255.0f
alpha:1.0f];
viewTopBar.frame = CGRectMake(0,25,320,40);
UIWebView *viewMusic = [[UIWebView alloc] init];
[self.view addSubview:viewMusic];
viewMusic.backgroundColor = [UIColor blackColor];
viewMusic.frame = CGRectMake(0,65,320,270);
viewMusic.mediaPlaybackRequiresUserAction=NO;
viewMusic.allowsInlineMediaPlayback = YES;
NSBundle* bundle = [NSBundle mainBundle];
NSString* path = [bundle pathForResource: @"index" ofType: @"html"];
NSURL* url = [NSURL fileURLWithPath: path];
NSURLRequest* req = [NSURLRequest requestWithURL: url];
[viewMusic loadRequest: req];
UIImageView *imageFBButton = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"loginfb.gif"]];
imageFBButton.frame = CGRectMake(43, 421, 234, 49);
[self.view addSubview:imageFBButton];
}
@end
我试过你的密码。它加载的图像没有任何问题。我相信这是一个糟糕的资源,或者像“雷姆斯”所说的那样缺失。附上屏幕截图。您可以在指定的位置看到google图像
您的资源包中是否有名为“loginfb.gif”的图像?请在
imageFBButton.frame=CGRectMake(43421234,49)处添加断点代码>然后将鼠标悬停在imageFBButton
上并单击眼睛图标。你看到图像了吗?图像在应用程序中folder@remus它说无法加载ImageFBButton的数据,这是一个坏的资源或丢失。仔细检查是否已添加到目标中?