サインインからの応答を受け取ったときに、アプリケーション全体にアラート ボックスを表示したい
どのように可能ですか?
使えますNSNotification
か?
サインインからの応答を受け取ったときに、アプリケーション全体にアラート ボックスを表示したい
どのように可能ですか?
使えますNSNotification
か?
appdelegateにパブリックメソッドを配置して、アラートビューを表示させることができます。
次のようにアプリデリゲートにアクセスできます。
[UIApplication sharedApplication].delegate
警告を防ぐために、アプリデリゲートクラスにキャストする必要があります。その後、メッセージを送信できます。
[(MyAppDelegate *)[UIApplication sharedApplication].delegate showMyAlertView];
- (void)afterSignIn
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Message" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
通知の作成と受信は簡単です。
1)オブザーバー(たとえば、YourViewController
)を通知に追加します。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(someEventHappend)
name:@"SomeEvent" object:nil];
このコードをviewDidLoad
メソッドに追加する必要があります。
someEventHappend
2)メソッドを実装するYourViewController
3)サインインからの応答をgitしたときに通知を投稿します。
[[NSNotificationCenter defaultCenter] postNotificationName:@"SomeEvent" object:nil];
その後、メソッドNSNotificationCenter
を呼び出しますsomeEventHappend
YourViewController
@anil を 1 つ取り、これを Global.h の「BOOL Signin」値に設定します。それが true の場合、次のように変更ビューを表示します
-(void)afterSignIn
{
if(Signin == YES)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Meassage" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
}
NSNotificationCenter の使用は必須ではありません