如何在iOS中创建自己的自定义监听器?

时间:2015-08-01 06:51:59

标签: ios objective-c iphone ipad

我有两个关于哪些图像从服务器加载的视图。图像是异步加载的。所以当加载图像时我想调用一个函数或执行一个代码块。那我怎样才能创建一个监听的监听器加载图像。我在视图上有三个图像,用于加载我在代码下方使用的每个图像,以从服务器加载图像。

 dispatch_async(queue, ^{


            NSString *urlString=[IMAGE_BASE_URL stringByAppendingString:bc.logo];
            NSLog(@"logo url is %@",urlString);
            NSURL *logo_url = [NSURL URLWithString:urlString];
            NSData  *logo_image_data= [NSData dataWithContentsOfURL:logo_url];

            UIImage *logo_imge= [UIImage imageWithData:logo_image_data];
            dispatch_async(dispatch_get_main_queue(), ^{

                     self.img_front_logo.image = logo_imge;




            });
        });

我希望在我的课程中收到所有三张图片的加载时的通知。

我是iOS的初学者,所以对此没有任何想法?

1 个答案:

答案 0 :(得分:0)

请使用此代码

aCities = ['MELBOURNE', 'SYDNEY', 'PERTH', 'DUBAI', 'LONDON']

cxTrx = db.cursor()
cxTrx.execute( 'SELECT desc FROM AccountingRecords' )

for row in cxTrx.fetchall() :
    if any( city in row[0] for city in aCities ) :
        #print the name of the city that fired the any() function
    else :
        # no city name found in the accounting record
相关问题