-1

UIAlertView 委托没有被调用。警报正在显示,但按钮不起作用。我想要一个按钮打开谷歌地图,另一个按钮打开本地地图应用程序。

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

if([title isEqualToString:@"Mapes"])
{
    UIApplication *ourApplication = [UIApplication sharedApplication];
    NSString *ourPath = @"http://maps.apple.com/?q=41.11670,1.25812";
    NSURL *ourURL = [NSURL URLWithString:ourPath];
    [ourApplication openURL:ourURL];

}
if([title isEqualToString:@"Google Maps"])
{
    UIApplication *ourApplication = [UIApplication sharedApplication];
    NSString *ourPath = @"http://maps.apple.com/?q=41.11670,1.25812";
    NSURL *ourURL = [NSURL URLWithString:ourPath];
    [ourApplication openURL:ourURL];
}
}
@end
4

1 回答 1

1

转变 :

 -(void)showAlertView:(UIAlertView *)alert clickedButtonAtIndex (NSInteger)otherButtonTitles

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
于 2013-07-27T16:45:48.477 回答