views:

271

answers:

2

Hi,

what I'm trying to do is to have 1. a speakable text withtin the cell of a tableview (let's say "Google") 2. the ability that the user is able to select this row ("Google") and safari starts and opens the url http://www.google.de 3. if the user adds a new entry to the tableview, he should be able to enter the speakable text and the attached url which should both be saved within the tableview

I've already searched at google quite some time, without success.

Is there a possibility to realize this with a tableview at all? Any hints, suggestions or what so ever are pretty much appreciated.

thank you for wour support in advance!

Daniel

A: 

Seems like this is something like I'm looking for:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic
if(indexPath.row == 0 && indexPath.section == 2){
  NSString * storyLink = [currentStory objectForKey: @"link"];

  // clean up the link - get rid of spaces, returns, and tabs...
  storyLink = [storyLink stringByReplacingOccurrencesOfString:@" " withString:@""];
  storyLink = [storyLink stringByReplacingOccurrencesOfString:@"\n" withString:@""];
  storyLink = [storyLink stringByReplacingOccurrencesOfString:@" " withString:@""];

 // NSLog(@"link: %@", storyLink);
  // open in Safari
  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:storyLink]];
}

}

The Problem then is still, how to give the user the possibility to make an own UITableView entry with a name for the link and the url itself (somewaht like a bookmark in safari).

Any suggestions?

A: 

You should have an attribute listLinks (NSMutableArray) linked with the content of your table (e.g numRowsForSection return [listLinks count], and the cellForRowAtIndexPath etc.)

Then just create a form and add the data to the list, and use reloadData on your UITableView.

Adapt then your didSelectRowAtIndexPath getting data from your listLinks and openURL on the sharedApplication.

F.Santoni