2016-08-09 33 views
-3

Ich bin ein Anfänger i in diff Weise versuchte, nicht so für Anregungen in ihmWie URL über die Methode "segue" an die Webansicht übergeben wird?

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

was yuour Frage ...? Was die Antwort erwarten Sie –

+0

was genau wollen Sie? –

+1

Identischer Identifikator für alle Segmente ??????? –

Antwort

0

Implementieren unter Methode und geben Sie Ihren Wunsch interessiere mich nicht funktioniert.

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

und eine Sache mehr, benutzen Sie nicht dieselbe Identifikation für alle Übergänge.

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

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

in DestinationClassName, erhalten WebUrl String und URL webURL.like mit make

NSURL *url = [NSURL URLWithString:self.webURL]; 
[self.webView loadRequest:[NSURLRequest requestWithURL:url];