2016-08-09 8 views
-3

私は私が差分の方法で試してみました初心者はとてもメソッドの下に実装し、その中にあなたの欲求オブジェクトを渡すの提案segueメソッドを使用してURLをWebビューに渡す方法は?

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 

    // Return the number of sections. 
    return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    // Return the number of rows in the section. 
     return self.objects.count; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *[email protected]"cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 
    cell.textLabel.text=self.objects[indexPath.row]; 
    return cell; 
} 

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
    ViewController *webview = [[ViewController alloc] init]; 
    if ([[segue identifier] isEqualToString:@"showdetails"]) 
    { // Facebook 
     NSString *[email protected]"https://www.facebook.com/"; 
     webview = [segue destinationViewController]; 
     webview.urlstr = urlstr; 
     webview.title = @"Facebook"; // this sets the title of the next page      
    } 
    else if ([[segue identifier] isEqualToString:@"showdetails"]) { // Instagram 
     NSString *[email protected]"http://instagram.com/"; 
     webview = [segue destinationViewController]; 
     webview.urlstr = urlstr; 
     webview.title = @"Instagram"; // this sets the title of the next page 
    } 
    else if ([[segue identifier] isEqualToString:@"showdetails"]) { // Twitter 
     NSString *[email protected]"https://twitter.com/"; 
     webview = [segue destinationViewController]; 
     webview.urlstr = urlstr; 
     webview.title = @"Twitter"; // this sets the title of the next pag 
    } 
    else if ([[segue identifier] isEqualToString:@"showdetails"]) { // YouTube 
     NSString *[email protected]"http://www.youtube.com/"; 
     webview = [segue destinationViewController]; 
     webview.urlstr = urlstr; 
     webview.title = @"YouTube"; // this sets the title of the next page 
    } 
    self.title = @"Follow"; // This sets the title of the back button, and the title of this page 

} 
+2

いただきましyuour質問を使用してURLを作りますか...?あなたは何を期待しているのでしょうか。 –

+0

どうしたらいいですか? –

+1

すべてのセグの同じ識別子??????? –

答えて

0

を探しています動作しませんよ。

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ 
    UINavigationController *navController = (UINavigationController *)segue.destinationViewController; 
    secondViewController *controller = (secondViewController *)navController; 
    NSString *[email protected]"https://www.facebook.com/"; 
    secondViewController.urlstr = urlstr; 
} 

さらに1つ、すべてのセグに同じ識別子を使用しないでください。 DestinationClassNameで

0
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
DestinationClassName *Object = (DestinationClassName *)segue.destinationViewController; 

     NSString *[email protected]"https://www.google.com/"; 
     Object.webURL = yrURL; 
} 

、webURL文字列を取得し、webURL.like

NSURL *url = [NSURL URLWithString:self.webURL]; 
[self.webView loadRequest:[NSURLRequest requestWithURL:url]; 
関連する問題