iPhone アプリの 1 つの更新に取り組んでいます。やったことのないことをしなければならない...
「ワンタイムコードで」UIAlert を使用して Safari ブラウザーで URL を起動したいと考えています。
もう少し説明させてください: UIAlert で Safari を起動したい場合は、次のように簡単に書くことができます:
- (void)OpenApple:(id)sender {
UIAlertView *URLApple = [[UIAlertView alloc] initWithTitle: NSLocalizedString(@"Open Apple",@"Open") message: NSLocalizedString(@"Want you open Apple",@"Apple") delegate: self cancelButtonTitle: NSLocalizedString(@"No", @"close") otherButtonTitles: NSLocalizedString(@"Yes", @"yes"), nil];
alertView.tag = TAG_URL;
[alertView show];
[alertView release];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
if ( alertView.tag == TAG_URL ) {
NSLog(@"Clicked button index 0");
// Do nothing
}} else {
if ( alertView.tag == TAG_URL ){
NSLog(@"Clicked button index other than 0");
NSURL *url = [NSURL URLWithString: NSLocalizedString(@"http://www.apple.com", @"URLApple")];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}}}}
でも今は「この2(ボイド)を1回で」やりたい…
簡単に言うと、上記の抜粋の最初の部分で外部 URL を開く必要があります。
それは少し似ています:
"UIAlertView *URLApple = [[UIAlertView alloc] initWithTitle: NSLocalizedString(@"Open Apple",@"Open") message: NSLocalizedString(@"Want you open Apple",@"Apple") delegate: self cancelButtonTitle: NSLocalizedString(@ "No", @"close") otherButtonTitles: NSLocalizedString(@"Yes", @"yes"), nil]; alertView.tag = TAG_URL; [alertView 表示]; [alertView リリース];
if @"yes" = [[UIApplication sharedApplication] canOpenURL:url] }"
-(void) alertView: (UIAlertView *)alert1: clickedButtonAtIndex:(NSInteger)buttonIndex{ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://apple. com"]];
簡単すぎる... 例として使用したコードの最初の部分で始まる何かが必要です ( (void)OpenApple:(id)sender {
UIAlertView *URLApple = [[UIAlertView alloc] initWithTitle: NSLocalizedString(@"Open Apple",@"Open") message: NSLocalizedString(@"Want you open Apple",@"Apple") delegate: self cancelButtonTitle: NSLocalizedString(@" No", @"close") otherButtonTitles: NSLocalizedString(@"Yes", @"yes"), nil]; alertView.tag = TAG_URL; [alertView ショー]; [alertView リリース]; } ) .
このコードの最初の部分には、私が開かなければならない URL が含まれている必要があります...
開く必要がある URL (Web サイトの URL ではない...) は、コードの別の部分 (別の "-(void)",合計で)。アラート、開始 URL をトリガーするアラート ボタン、および URL 自体は、コードの同じ部分に配置する必要があります。
出来ますか?これについて考えてみませんか?
事前に、私を助けてくれる人に感謝します。
CCCさん、よろしくお願いします。