使用 UISlider 的自定义图像不会显示在设备上
一切都可以在模拟器上正常运行。然而,当我把它放在我的设备上时,它只显示 ThumbImage
。这真的很奇怪。我认为这可能是 iOS 版本问题或内存问题。我的设备是 iPhone 3GS iOS 4.1。 Xcode 版本 3.2.5。
@interface BlueChalkSlider : UISlider {}
@end
@implementation BlueChalkSlider
- (id)initWithCoder:(NSCoder *)decoder {
if ((self = [super initWithCoder: decoder])) {
self.backgroundColor = [UIColor clearColor];
[self setThumbImage:[UIImage imageNamed:@"Chalk.png"] forState:UIControlStateNormal];
[self setMinimumTrackImage:[UIImage imageNamed:@"ChalklineBlue.png"] forState:UIControlStateNormal];
[self setMaximumTrackImage:[UIImage imageNamed:@"ChalklineWhite.png"] forState:UIControlStateNormal];
}
return self;
}
@end
Everything works on the simulator without a problem. However when I put it on my device it only show the ThumbImage
. It is just really strange. I'm thinking this could be a iOS version issue or memory issue. My device is iPhone 3GS iOS 4.1. Xcode Version 3.2.5.
@interface BlueChalkSlider : UISlider {}
@end
@implementation BlueChalkSlider
- (id)initWithCoder:(NSCoder *)decoder {
if ((self = [super initWithCoder: decoder])) {
self.backgroundColor = [UIColor clearColor];
[self setThumbImage:[UIImage imageNamed:@"Chalk.png"] forState:UIControlStateNormal];
[self setMinimumTrackImage:[UIImage imageNamed:@"ChalklineBlue.png"] forState:UIControlStateNormal];
[self setMaximumTrackImage:[UIImage imageNamed:@"ChalklineWhite.png"] forState:UIControlStateNormal];
}
return self;
}
@end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题解决了!!!
模拟器不区分大小写。设备区分大小写。我已经更改并确保所有文件名都与区分大小写完全相同。
例如
Chalkline
应该是ChalkLine
Problem Solved!!!
The simulator is NOT case sensitive. The Device is case sensitive. I've changed and make sure all my filenames are exactly the same with Case Sensitive.
e.g.
Chalkline
should beChalkLine
您是否复制资源文件(添加图像时是否选择复制图像)?尝试从“构建”(或“运行”?)菜单中执行“清理”...以及“构建和构建”。再次运行。
Are you copying the resource files over (did you choose to make a copy of the images when you added them)? Try a Clean from the Build (or Run?) menu...and Build & Run again.