简体   繁体   English

图片未在iPad上显示

[英]Image not showing on iPad

I have created an iOS APP for iPad and my application is using XIB. 我已经为iPad创建了一个iOS APP,并且我的应用程序正在使用XIB。 On XIB I have put a UIImageView and UIButtonview and set the image on both of them. 在XIB上,我放置了UIImageViewUIButtonview并在两个图像上都设置了图像。 The image is showing on XIB but when I am testing it on simulator then both of these views is not showing. 该图像显示在XIB上,但是当我在模拟器上对其进行测试时,这两个视图均未显示。 I have checked hidden and alpha of both views. 我已经检查了两个视图的隐藏和Alpha。

I have debugged my source code and found that it may be because of Alpha. 我调试了源代码,发现可能是由于Alpha所致。 You can see the attached screenshot. 您可以看到所附的屏幕截图。 I have not written any source code in my .m file, simply load the viewcontroller from xib But still it's Alfa is changing I don't how alfa is changing 我没有在我的.m文件中编写任何源代码,只需从xib加载viewcontroller,但仍然是Alfa正在更改,我没有Alfa在如何更改 在此处输入图片说明

In my project ,I am also using following source code 在我的项目中,我也在使用以下源代码

/***** MyView.h************/

@interface UIImageView (MyView)

- (void) setAlpha:(float)alpha ;

@end

/***** MyView.M************/

@implementation UIImageView (MyView)

- (void) setAlpha:(float)alpha 

 //here alpha value is always zero but under xib it's value is 1
 //I Don't know why here I am getting zero

{

    [super setAlpha:alpha];

}

@end

I don't know why it is happening, can anyone please help me. 我不知道为什么会这样,任何人都可以帮助我。

I got the solution my self I need to use "CGFloat" at the place of "float" 我得到了解决方案,需要在“ float”位置使用“ CGFloat”

/***** MyView.h************/

@interface UIImageView (MyView)

- (void) setAlpha:(CGFloat)alpha ;

@end

/***** MyView.M************/

@implementation UIImageView (MyView)

- (void) setAlpha:(CGFloat)alpha 
{

    [super setAlpha:alpha];

}

@end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM