PDA

View Full Version : Loading Image from XML URL




bradnet
May 15, 2011, 05:17 AM
Hi Guys

I followed the tutorial from the url posted below and managed to get the app running fine with a static url for the source and just some sample content and i have a couple of questions that i was hoping someone would be able to point me in the right directions for some tutorials that may help.

1) my first question is about concatenating responses to form a url, i would ask the user to answer appx 4 or 5 questions which will give them a directory structure depending on there responses and then concatenate it all together to give a url to download the xml from?

2) my second question is whether i would be able to load an image large enough to fill the screen at the bottom of the table either as a customized cell big enough to hold an image the size of the full screen, or in an image view added in the xib under the tableview (but will it be constrained to the size of the image view added to the xib?)or using a cell in the final detail to open a further detail view showing the image?

any help, tutorials or source you can provide would be much appreciated.

http://www.edumobile.org/iphone/iphone-programming-tutorials/parsing-an-xml-file/

Thanks
Brad



jnoxx
May 15, 2011, 06:32 AM
Yes and yes.

1st question.

Basicly you could put 5 textfields in a view. attach them via IB -->

IBOutlet UITextField *question1Field;
IBOutlet UITextField *question2Field;

Something like that.
Then when they press a button attach an IBAction


- (IBAction) loadXMLCorrectURL:(id)sender {
NSString *urlString = [[NSString alloc] initWithFormat:@"http://www.herpderp.com/%@/%@/%@", question1field.text, question2field.text, question3field.text];

[urlString release];
}

THat will set you on your way.

For the second question.
U can load an image as big as u want in theory. U can insert one in the XIB, a UIImageview, and fill it with NSData u get from the specific URL on every page, think that would be easiest for u, and insert it on top of ur Page or whatever.
Or u do a count on the array u fill ur tableview with, add 1.
And on that specific cell, u can add an custom tableviewcell, and fill it with a image.

Enough information to go on?

bradnet
May 15, 2011, 06:59 AM
It's ok doesnt matter i placed the button under the tableview i should have put it in the footer of the table rather than outside of the view.

Thanks
Brad

hi jnoxx

thanks that was a great reply it will keep me busy for a while implementing it i just have one more little question, i have tried adding a button and also other controls to the original xib i created from the previous tutorial but unfortunately none of them are showing on the screen, will this be down to the wrong hookup for the delegate or something else i've not considered.

thanks for the help, it's much appreciated.

Brad

bradnet
May 15, 2011, 02:16 PM
Hi

I've decided that i would need this navigation controller with other pages for asking for the details and other such information so i have created a tab bar application and created the navigation controller in this app using the code from the posting above but when i load the second tab with the xib for the navigation controller and change the class type to Navigation controller the page is blank no rows no sections just a blank page, i think i may have the files owner or the datasource or delegate hooked up wrong.

Any help would be appreciated.

thanks
Brad

jnoxx
May 16, 2011, 06:59 AM
Well, the second page u are pushing inside this Tab, u sure this is all setted up correctly.
If u go to your mainwindow, it has a navigation controller as a tab?
And inside your code, u imported the file to push it via navigation, and u are sure ur loading the right XIB?

Otherwise instead of doing

SecondViewController *secondVC = [[SecondViewController alloc] init];

try this.

SecondViewController *baseVC = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];

And make sure u use the right Nibname (XIB in other words.).

Hope that helps, otherwise i'll check on here soon.

bradnet
May 16, 2011, 04:09 PM
Hi Guys

I've now decided on a different root so i can have the tableview as the second option in a tabbar so i have tried to intergrate the following two tutorials but with no success i can get the tabbarcontroller to load with a tableview in the second tab but i can't get any contents to show in the table.

I have the correct nib name's loaded into the mainwindow.xib tabbar settings and i have the delegate's setup as per the video and the header files imported in the tableviewcontroller so i can reference the book array but i still get no content in the table i must have a delegate or datasource wrong somewhere.

XMLParser
http://www.edumobile.org/iphone/iphone-programming-tutorials/parsing-an-xml-file/

http://www.youtube.com/watch?v=LBnPfAtswgw

I've created all the relevant files such as the book.h and .m and the xmlparser files but i presume the declarations that would normally go in the RootViewController should go in the BooksTableViewController.h, and anything that should be in the xmlappdelegate should go in my new new appdelegate and i have imported the book.h into the BooksTableViewController.m but i think this may be my problem but i'm not sure

Book *aBook = [appDelegate.books objectAtIndex:indexPath.row];

is the bookstableviewcontroller the appDelegate or should i be referencing the tabbar controller as appDelegate.

I think i'm just confusing myself the more i think about it, any tips would be apreciated.

Thanks
Brad