我正在为我的公司拼凑一个应用程序,并在选择表格视图中的单元格时打开pdf文件,或者让它打开pdf所在的网址。我已经构建了表视图,我只想完成应用程序的这一部分来完成它。任何想法都会很棒。
@implementation RootViewController
- (void)viewDidLoad {
[super viewDidLoad];
//Initialize the array.
listOfItems = [[NSMutableArray alloc] init];
NSArray *currentarry = [NSArray arrayWithObjects:@"MARCH 2014", nil];
NSDictionary *currentInDict = [NSDictionary dictionaryWithObject:currentIssueArray forKey:@"Issues"];
NSArray *previousIssueArray = [NSArray arrayWithObjects:@"JANUARY 2014 ", nil];
NSDictionary *PreviousinDict = [NSDictionary dictionaryWithObject:previousIssueArray forKey:@"Issues"];
[listOfItems addObject:Current];
[listOfItems addObject:Previous];
//Initialize the copy array.
copyListOfItems = [[NSMutableArray alloc] init];
//Set the title
self.navigationItem.title = @"Title";
答案 0 :(得分:0)
这样可以解决问题:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com"]];
答案 1 :(得分:0)
您应该使用index
方法获取与您要打开的URL
相关的单元格tableView: didSelectRowAtIndexPath:
,如此(假设URL
字符串显示在单元格上,或者您可以从其他地方获取它:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSString *cellText = cell.textLabel.text;
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:cellText]];
}