gpt4 book ai didi

iphone - uialertview 不执行任何操作

转载 作者:行者123 更新时间:2023-11-29 03:44:01 25 4
gpt4 key购买 nike

我必须使用两个按钮放置一个警报 View ,但这些按钮不会打开网址。我不知道错误。请帮忙。

代码如下:

-(IBAction)showAlertView {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Obrir en..."
message:@"Es pot requirir la aplicació de Google Maps"
delegate:self
cancelButtonTitle:@"Millor no..."
otherButtonTitles:@"Mapes",@"Google Maps",nil];
[alert show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];

if([title isEqualToString:@"Mapes"])
{
UIApplication *ourApplication = [UIApplication sharedApplication];
NSString *ourPath = @"http://maps.apple.com/?q=Plaça+del+Rei+43003+Tarragona";
NSURL *ourURL = [NSURL URLWithString:ourPath];
[ourApplication openURL:ourURL];

}
if([title isEqualToString:@"Google Maps"])
{
UIApplication *ourApplication = [UIApplication sharedApplication];
NSString *ourPath = @"comgooglemaps://?daddr=Plaça+del+Rei+43003+Tarragona&directionsmode=walking";
NSURL *ourURL = [NSURL URLWithString:ourPath];
[ourApplication openURL:ourURL];
}
}

最佳答案

您必须对 urlString 进行 url 编码,因为它包含一些特殊字符。

NSString *ourPath = @"http://maps.apple.com/?q=Plaça+del+Rei+43003+Tarragona";
ourPath=[ourPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

关于iphone - uialertview 不执行任何操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17971745/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com