【发布时间】: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