【问题标题】:Loading a Wikipedia page加载维基百科页面
【发布时间】:2010-12-26 17:57:22
【问题描述】:

我想在UIAlertView 中创建一个按钮,用于打开一个维基百科页面,主题存储在我的数组“array”中

这就是我的做法。

维基百科遵循http://en.wikipedia.org/wiki/<subject> 的格式。在我的数组中,我有主题的文本条目。我希望它在点击时在移动 Safari 中打开。到目前为止,没有运气:(

请帮忙。任何见解将不胜感激。

-(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 ]];

}

【问题讨论】:

    标签: cocoa-touch nsurl


    【解决方案1】:

    哦,原来我需要用 % 替换数组中字符串中的间隙才能作为正确的链接,所以它会打开。,

    【讨论】:

      猜你喜欢
      • 2011-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-08
      • 2016-03-27
      • 2016-10-11
      • 1970-01-01
      相关资源
      最近更新 更多