我在我的应用程序中实现了NSNotificationCenter.我在完成图像解码时发送通知.第一次图像解码将完成8次.所以通知假设发送8次.但它调用64次(8*8).
这是我的代码我是如何实现的 - > //初始化
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(getHRImage:)
name:@"DecodeComplete" object:nil];}
Run Code Online (Sandbox Code Playgroud)
//调用方法
-(void)getHRImage:(NSNotification *) notification
{
if ([[notification name] isEqualToString:@"DecodeComplete"])
NSLog (@"Successfully received the DecodeComplete notification! ");
}`
Run Code Online (Sandbox Code Playgroud)
//解除分配
- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"DecodeComplete" object:self];
//[super dealloc];
}
Run Code Online (Sandbox Code Playgroud)
//发布通知
[[NSNotificationCenter defaultCenter] postNotificationName:@"DecodeComplete" object:self];
Run Code Online (Sandbox Code Playgroud)
有人可以建议我做错了.
提前致谢.
//调用方法是这样的(调用8次)
-(void)decode
{
NSLog(@"---------- Decoding is Complete ---------");
[[NSNotificationCenter defaultCenter] postNotificationName:@"MdjDecodeComplete" object:self];
}
Run Code Online (Sandbox Code Playgroud) 我的应用程序是一种图片库.当用户点击图库中的图标时,需要显示图像(横向2图像,纵向1图像).图片可能超过100.我通常采用原始文件并解码为UIImage格式.如果用户想要看到另一个图像,则由于解码而花费一些时间(延迟)来显示图像.所以我想在一个单独的线程(GCD)中将一些图像保存到缓存(NSArray)中以解决此问题.
在阵列中,我可以存储5到10个图像.每次用户滑动时都需要更新.
请提出建议.
提前致谢.
几个月前我将Android APK发送给了我的客户.那时它已成功安装,但同样的APK现在不想在任何设备上安装(应用程序未安装).
我再次生成了一个新的未签名APK,但是那个也没有安装任何设备.所以我现在生成了一个签名的APK,它已成功安装在所有设备中.
注意:我使用Eclipse生成了APK.
Android APK创建有任何变化吗?