iphone - uialertview don't do action -
i have put alert view 2 buttons, buttons don't open urls. don't know error. please.
here's code:
-(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]; } }
you have url encoding urlstring because contain special character.
nsstring *ourpath = @"http://maps.apple.com/?q=plaça+del+rei+43003+tarragona"; ourpath=[ourpath stringbyaddingpercentescapesusingencoding:nsutf8stringencoding];
Comments
Post a Comment