0

iOSの新機能。

引数をハードコーディングして、文字列として URLWithString に渡すと、次のように機能します。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
UIApplication *ourApplication = [UIApplication sharedApplication];
NSURL *url = [NSURL URLWithString:@"http://files.parse.com/81b196c3-d103-4db1-bb6f-0c74acedfa8c/5f0718e2-a79a-454c-ae9c-082ba28a74-Kontractor_test2.pdf"];
[ourApplication openURL:url];
}

しかし、 object: メソッドを追加してから変数を URLWithString: に渡すと、次のようになります

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
{
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.textLabel.text = [object objectForKey:@"link"];
NSString *fileURL;
fileURL = cell.textLabel.text;
UIApplication *ourApplication = [UIApplication sharedApplication];
NSURL *url = [NSURL URLWithString:fileURL];
[ourApplication openURL:url];
}

テーブル セルをクリックしても、シミュレータでブラウザが表示されません。なぜこれが起こっているのですか?ありがとうございました

4

1 に答える 1

0

渡す URL は、シミュレーターでサポートされていない必要があります (tel:、ローカル リソースなど)。

于 2012-05-31T15:54:16.990 に答える