开发者

Loading a Wikipedia page

I want to make a button in an UIAlertView that opens a Wikipedia page, with a subject stored in my array "array"

Here is how I'm doing it.

Wikipedia follows the format of http://en.wikipedia.org/wik开发者_如何转开发i/<subject>. In my array, I have text entries of subjects. I want it to open in mobile Safari when tapped. So far, no luck :(

Help please. Any insight would be appreciated.

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 1) {

NSString *myString = [[NSString alloc] init];

myString = [array objectAtIndex:myInteger];

NSURL *theURL = [NSURL URLWithString:@"http://en.wikipedia.org/wiki/"];
NSString *halfURL = [NSString stringWithFormat:@"%@", theURL];
NSString *fullURL = [halfURL stringByAppendingString:myString];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:fullURL ]];

}


oh, turns out that i needed to replace the gaps in the strings in the arrays with % to work as a proper link, so it would open.,

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜