Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-21-2012, 05:15 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 2
Bricolaureate is on a distinguished road
Default load URL from plist in drill down

Hello,
I'm very new and thankful for any help.
I have been working on a drill down app based on the tutorial that is supposed to feed the URL in the detailViewController.

I have success in loading the URL but can only pull the URL from the first row of the second table, when really the URL should be the first line of the second table based on x line of the first table.

I tried nested if statements and could not get that to work. And I have been trying to find the correct code to load it from the data in the plist.

I would be happy with either solution (if statements or data in the plist) though I think the data would make cleaner code (I don't really want to hard code in all the URLs)

Please help..and thank you.



- (void)tableViewUITableView *)tableView didSelectRowAtIndexPathNSIndexPath *)indexPath {

//Get the dictionary of the selected data source.
NSDictionary *dictionary = [self.tableDataSource objectAtIndex:indexPath.row];

//Get the children of the present item.
NSArray *Children = [dictionary objectForKey:@"Children"];

//this doesn't work// NSString *MyUrl = [(NSString *)object_getClassName(data.MyURL)];



if([Children count] == 0) {

DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:[NSBundle mainBundle]];


UIWebView *uiWebView = [[[UIWebView alloc] initWithFrame: CGRectMake(0,0,320,480)] autorelease];


if ([self.title isEqualToString:@"Title One"]){ //if the tableview row with this title is selected
if (indexPath.row == 0) { //the [uiWebView loadRequest:

[uiWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]]];
} else if (indexPath.row == 1) { //the second subrow
[uiWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.amazon.com"]]];
} else { //any other subrows
[uiWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.yahoo.com"]]];
}
} else if ([self.title isEqualToString:@"Item 2"]){ //if the tableview row with this title is selected
if (indexPath.row == 0) { //then the first subrow will open this webview URL
[uiWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.coles.com.au"]]];
} else { //any other subrows will open this one
[uiWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.cdu.edu.au.html"]]];
}
}
else { // for any other top level tableview rows
if (indexPath.row == 0) { // the first subrow
[uiWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.wikipedia.com"]]];
} else { //any other subrows
[uiWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.ebay.com.au"]]];
}
}

uiWebView.scalesPageToFit = YES; // uiWebView - object of UiWebview

[dvController.view addSubview:uiWebView];


[self.navigationController pushViewController:dvController animated:YES];

}

[dvController release];

else {

//Prepare to tableview.
RootViewController *rvController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:[NSBundle mainBundle]];

//Increment the Current View
rvController.CurrentLevel += 1;

//Set the title;
rvController.CurrentTitle = [dictionary objectForKey:@"Title"];

//Push the new table view on the stack
[self.navigationController pushViewController:rvController animated:YES];

rvController.tableDataSource = Children;

[rvController release];
}
}


And here is the .plist
Rows - Array
Item 0 - Dictionary
Title String Title One
Children Array
Item 0 Dictionary
Title String Child One
MyURL String "Http://www.google.com"
Item 1 Dictionary
Title String Child Two
MyURL String "Http://www.ebay.com"
Item 1 - Dictionary
Title String Title Two
Children Array
Item 0 Dictionary
Title String Second Child One
My URL Sting "Http://www.target.com"

etc...
Bricolaureate is offline   Reply With Quote
Reply

Bookmarks

Tags
drill down table view, plist, url loading, webview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 393
10 members and 383 guests
7twenty7, Atatator, FrankWeller, glenn_sayers, guusleijsten, iphonedevshani, MAMN84, QuantumDoja, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,674
Threads: 94,122
Posts: 402,907
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Atatator
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:46 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0