私はUIViewController
別のものをもたらすボタンを持っていますUIViewController
。my に示すように、ボタンをクリックしてNSLog
、これが完了したら、通知を送信して別のviewcontroller
. さて、すべてが正しく行われているように見えますが、どういうわけか機能せず、表示されませんUIViewController
。コードは次のとおりです。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(infoPage:)
name:@"InfoPage" object:nil ];
-(void) infoPage:(NSNotification*)notification
{
NSLog(@"Code executing in Thread %@",[NSThread currentThread] );
InfoCtrol *i = [[InfoCtrol alloc] init];
i.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:i animated:YES];
}
私のタブバアイテムボタン
-(void)info {
[[NSNotificationCenter defaultCenter] postNotificationName:@"InfoPage"
object:nil
userInfo:nil];
NSLog(@"test not");
}
私の問題は次のとおりだと思います: mainThread にはありませんが、それをどのように解決すればよいかわかりません:
私もこれを使用しましたが、UIViewController をもたらしませんでした:
[self performSelectorOnMainThread:@selector(test) withObject:nil waitUntilDone:NO];
-(void)test{
[[NSNotificationCenter defaultCenter] postNotificationName:@"InfoPage"
object:nil
userInfo:nil];
}
このコードをボタンに入れるとUIViewController
、が表示されますが、使用したいNSNotificationCenter
InfoCtrol *i = [[InfoCtrol alloc] init];
i.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:i animated:YES];
私のログ:
Code executing in Thread <NSThread: 0x1fd7c7e0>{name = (null), num = 1}
アップデート:
How should i remove last thread from mainThread