いくつかのラベルを表示するためのcollectionviewセルがあります。私はdidselectを実行すると、別のViewControllerにラベル名で 'NSNotificationCenter'を使用して通知を発行する必要があります。しかし、コレクションセルでラベルを選択すると、通知は読み込まれますが、別のビューコントロールにはトリガーされません。あなたはセルをdidSelectedすると誰も私に解決CollectionViewCellでNotificationCenterが呼び出されていない
- (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は、今回のallocされていないことができますコード? –
あなたの問題とは無関係ですが、 "NSDictionary * dict = @ {@"タグ ":SearchTag};"あなたの辞書を作成する。更新された構文は、より短く、読みやすくなりました。 – ekscrypto
このような通知を印刷しても問題ありません。 - (void)receivedNotification:(NSNotification *)通知{NSLog(@ "%@"、notification.userInfo); NSLog(@ "Notification Received");} –