[英]NotificationCenter not called in CollectionViewCell did select
I have a collectionview cell for to display some labels, when I do didselect I have to fire a notification using 'NSNotificationCenter' with the label name to another viewcontroller . 我有一个collectionview单元格用于显示一些标签,当我执行didselect时,必须使用带有标签名称的'NSNotificationCenter'向另一个viewcontroller触发通知。 But when i select a label in collectioncell , The notification is read, but not triggered to another viewcontroller. 但是,当我在collectioncell中选择一个标签时,将读取通知,但不会将其触发到另一个viewcontroller。 Can anyone suggest me a solution 谁能建议我一个解决方案
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
NSString *SearchTag;
for(int i = 0; i < (int)[_taglinkarray[indexPath.row] count] ; i++)
{
if([[_taglinkarray[indexPath.row][i] valueForKey:@"profileFieldType"] isEqualToString:@"certificate"])
{
SearchTag = _tagarray[indexPath.row];
NSLog(@"tag name ------->%@",_tagarray[indexPath.row]);
NSDictionary * dict =[NSDictionary dictionaryWithObject:SearchTag forKey:@"Tags"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"NOTIFICATION" object:nil userInfo:dict];
}
}
}
In Another VC
//In DidLoad()
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(receivedNotification:)
name:@"NOTIFICATION" object:nil];
-(void)receivedNotification:(NSNotification*) notification
{
NSLog(@"Notification Received ");
}
当您没有选择一个单元格并发布通知时,但是这次没有分配另一个UIViewController,因此您不会收到通知,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.