ユーザーが「otherbutton」をタップすると、それは自分のリンクに移動します。 しかし、一度ボタンを押すと、何もしません。私のiPhone上UIAlertView。 openURLとしてotherbuttonを使用しています。
申し訳ありませんイムので、私はコード
用ペーストビンを使用しましたあなたのUIAlertView
のdelegate
がクラス(ほとんどの場合、self
)に設定する必要があります
ユーザーが「otherbutton」をタップすると、それは自分のリンクに移動します。 しかし、一度ボタンを押すと、何もしません。私のiPhone上UIAlertView。 openURLとしてotherbuttonを使用しています。
申し訳ありませんイムので、私はコード
用ペーストビンを使用しましたあなたのUIAlertView
のdelegate
がクラス(ほとんどの場合、self
)に設定する必要があります
コントローラクラスをUIAlertViewDelegateプロトコルに準拠させます。
@interface MyViewController : UIViewController <UIAlertViewDelegate>
自己に設定デリゲートでアラートビューを作成します(!buttonIndex = [alertView cancelButtonIndex])場合は、デリゲートメソッド
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex != [alertView cancelButtonIndex]) {
// open url
}
}
たくさん感謝それはそれを使用しています。 UIAlertView
を呼び出すクラスがUIAlertViewDelegate
デリゲートに準拠していることを確認してください。
UIAlertView
のdelegate
プロパティをnil
の代わりにself
に設定し、ヘッダーにプロトコルを実装する必要があります。
ヘッダーファイル:
@interface MyViewController : UIViewController <UIAlertViewDelegate>
はまた、buttonIndex
をチェック。現在、(上記を実行した後に)のいずれかのボタンを押すとURLが開きます。
- (void)alertView: (UIAlertView *)alertView clickedButtonAtIndex: (NSInteger)buttonIndex
{
if (buttonIndex != [alertView cancelButtonIndex])
{
//open url
}
}
へ
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Follow" message:@"me on twitter" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil]; [alert show]; [alert release];
応答しはする必要があります! –
ありがとうございました。 – Laaaa