在視圖中,我顯示的圖像是從coredata中提取的,我使用caroseul類顯示的圖像。在相同的觀點,我有Facebook按鈕,將導航到另一個屏幕。當我點擊Facebook按鈕時,操作不會執行,圖像加載後只有下一個屏幕即將到來,只要點擊它,按鈕操作就不會被調用。performselectorinBackground現在正在工作
在viewDidLoad中我呼籲:
[self performSelectorInBackground:@selector(popularImages) withObject:nil];
的popularImages方法:
- (void)popularImages
{
NSFetchRequest *request = [[NSFetchRequest alloc] initWithEntityName:@"Deals"];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ispopular == 1"];
[request setPredicate:predicate];
NSLog(@"popular Hypes called");
[self.managedObjectContext executeFetchRequest:request returnManagedObjectIDs:NO onSuccess:^(NSArray *deals) {
deals123 = [[NSMutableArray alloc] initWithArray:deals];
ij = 1;
for (Deals *deals in deals123) {
customizedMessage = [deals valueForKeyPath:@"txtmsgrec"];
dealIdString = [deals valueForKeyPath:@"dealsId"];
descriptionStr = [deals valueForKeyPath:@"dealdescription"];
captionStrArray = [deals valueForKeyPath:@"dealsassets.caption"];
[customizedMessageDict setObject:customizedMessage forKey:[NSString stringWithFormat:@"dealid%d",ij]];
[dealDict setObject:customizedMessageDict forKey:@"dealsmessage"];
[dealsIdDict setObject:dealIdString forKey:[NSString stringWithFormat:@"dealid%d",ij]];
[dealDict setObject:dealsIdDict forKey:@"dealsId"];
NSDictionary *dict = [NSDictionary dictionaryWithObject:captionStrArray forKey:@"caption"];
NSArray *captionTemparr = [[dict objectForKey:@"caption"] allObjects];
NSArray *assets = [deals valueForKeyPath:@"dealsassets.dealassetid"];
NSDictionary *dealassetidDict = [NSDictionary dictionaryWithObject:assets forKey:@"dealassetid"];
NSArray *dealassetidTemparr = [[dealassetidDict objectForKey:@"dealassetid"] allObjects];
[dealsUrlDict setObject:[[dealassetidDict objectForKey:@"dealassetid"] allObjects] forKey:[NSString stringWithFormat:@"dealid%d",ij]];
[dealDict setObject:dealsUrlDict forKey:@"delasURL"];
[dealsdescriptionDict setObject:descriptionStr forKey:[NSString stringWithFormat:@"dealid%d",ij]];
[dealDict setObject:dealsdescriptionDict forKey:@"dealsDescription"];
[dealscaptionDict setObject:captionTemparr forKey:[NSString stringWithFormat:@"dealid%d",ij]];
[dealDict setObject:dealscaptionDict forKey:@"dealscaption"];
ij++;
}
NSArray *array = [[dealDict valueForKey:@"delasURL"]allKeys];
NSLog(@"allKeys]class %@",[[[dealDict valueForKey:@"delasURL"]allKeys]class]);
NSDictionary *dealurlDict = [dealDict valueForKey:@"delasURL"];
NSDictionary *dealDescDict = [dealDict valueForKey:@"dealsDescription"];
NSDictionary *dealCaptionDict = [dealDict valueForKey:@"dealscaption"];
NSDictionary *dealIDDict = [dealDict valueForKey:@"dealsId"];
NSDictionary *dealMessageDict = [dealDict valueForKey:@"dealsmessage"];
for(int i=0;i<[array count];i++)
{
NSString *keyvalue = (NSString *)[array objectAtIndex:i];
NSString *dealId = [dealIDDict valueForKey:keyvalue];
NSArray *dealUrl = [dealurlDict valueForKey:keyvalue];
NSString *dealdesc = [dealDescDict valueForKey:keyvalue];
NSArray *dealcaption = [dealCaptionDict valueForKey:keyvalue];
NSString *dealMessage = [dealMessageDict valueForKey:keyvalue];
if([dealUrl count] == [dealcaption count])
{
//[dealUrl enumerateObjectsUsingBlock:^(id obj,NSUInteger idx,BOOL *stop)
for(int j = 0; j<[dealUrl count]; j++)
{
PopularHypesModal *dobject = [[PopularHypesModal alloc]init];
dobject.dealsID = dealId;
dobject.dealDescription = dealdesc;
dobject.dealcaption = [dealcaption objectAtIndex:j];
dobject.dealsUrl = [dealUrl objectAtIndex:j];
dobject.dealsMessage = dealMessage;
[self.items addObject:dobject];
[dobject release];
}
}
else
{
//[dealUrl enumerateObjectsUsingBlock:^(id obj,NSUInteger idx,BOOL *stop)
for(int j=0;j<[dealUrl count];j++)
{
PopularHypesModal *dobject=[[PopularHypesModal alloc]init];
dobject.dealsID = dealId;
dobject.dealDescription = dealdesc;
dobject.dealsMessage = dealMessage;
if([dealcaption count]>0)
{
dobject.dealcaption =[dealcaption objectAtIndex:0];
}
dobject.dealsUrl=[dealUrl objectAtIndex:j];
[self.items addObject:dobject];
[dobject release];
}
// ];
}
}
//];
carousel.dataSource = self;
carousel.delegate = self;
}onFailure:^(NSError *error) {
NSLog(@"Error fetching: %@", error);
popularHypes = YES;
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Server Problem" message:@"Sorry, There is some Error with server,Please try after some time" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
[alert show];
[alert release];
ij++;
}];//1st
[dealDict retain];
}
的按鈕i廈門國際銀行有加,我怎樣才能克服這一點。請幫我解決這個問題。
不,它不工作,同樣的事情發生,它需要一些時間來移動到Facebook屏幕。 – iOSDev