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 10-12-2011, 09:52 AM   #1 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 36
svenJ is on a distinguished road
Default Create instance of view controller / trigger didSelectRowAtIndexPath

What I'm working on
I'm working on a news app. A tableview with news items and more information when you click an item.

What I've done
Parse an online XML document. Display images + title from XML document and put it in a Table View. Works fine here. I also created a .h and .m file for the detailed news view. It contains a larger image and text, all dummy and placeholders.

Where I need your help
I need to connect each newsitem with this detailed view. I'm kinda stuck here.. I've tested my code as far as seeing weather I have all the data I need:

Code:
NSString *testString = [blogEntries objectAtIndex:indexPath.row];
NSString *msg = [[NSString alloc] initWithFormat:@"Current item selected: %@", testString];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Test item" message:msg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];  

[alert show];     
[alert release];
[testString release];
[msg release];
The code above works fine. It displayed the complete node from my XML document. What I want is an instance from newsDetailView.h / newsDetailsView.m and fill it up with the information from the current selected item. And slide it in from the right of the screen.

The code below works but, needless to say, it doesn't fill the dummy text and placeholders with the actual values. How do I do that?

Code:
nieuwsDetailView *NieuwsDetailView = [[nieuwsDetailView alloc] initWithNibName:@"NieuwsDetailView" bundle:nil];
[self.navigationController pushViewController:NieuwsDetailView animated:YES];
[NieuwsDetailView release];
Thanks in advance, I really appreciate any help!
svenJ is offline   Reply With Quote
Old 10-12-2011, 09:59 AM   #2 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

You need to make a property in your NieuwsDetailView (most likely NSString) in which you will set the text you want after you alloc/init it. Then in the controller's (NieuwsDetailView) viewDidLoad method you can grab that value and display it where you want.
baja_yu is offline   Reply With Quote
Old 10-13-2011, 07:09 AM   #3 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 36
svenJ is on a distinguished road
Default

Quote:
Originally Posted by baja_yu View Post
You need to make a property in your NieuwsDetailView (most likely NSString) in which you will set the text you want after you alloc/init it. Then in the controller's (NieuwsDetailView) viewDidLoad method you can grab that value and display it where you want.
Thank you for your reply. The problem is; I don't know how to do that.. Do you have an example code or know where to got it maybe?

edit:
Also, the following code:

Code:
nieuwsDetailView *NieuwsDetailView = [[nieuwsDetailView alloc] initWithNibName:@"NieuwsDetailView" bundle:nil];
[self.navigationController pushViewController:NieuwsDetailView animated:YES];
[NieuwsDetailView release];
may be complete different. I think it doesn't need to push an view initiated with an Nib because, well I have a nib file, but I've created it completely programmatically. My NIB file is empty.

(As you might have guessed I'm kinda new and still struggling putting the pieces together)

Last edited by svenJ; 10-13-2011 at 07:16 AM.
svenJ is offline   Reply With Quote
Old 10-14-2011, 01:37 AM   #4 (permalink)
Registered Member
 
Join Date: Sep 2010
Location: Skattkärr, Sweden
Posts: 9
BinHex is on a distinguished road
Default

Do this…

nieuwsDetailView.h
@interface nieuwsDetailView: UIViewController

@property(retain, nonatomic) NSString* theTestString;


theTableViewController.m

/* if a nib file */
nieuwsDetailView *NieuwsDetailView = [[nieuwsDetailView alloc] initWithNibName:@"NieuwsDetailView" bundle:nil];

/* pass the testString value to theTestString property in the detail view */
NieuwsDetailView.theTestString = testString;


[self.navigationController pushViewController:NieuwsDetailView animated:YES];
[NieuwsDetailView release];

Last edited by BinHex; 10-14-2011 at 01:44 AM.
BinHex is offline   Reply With Quote
Old 10-14-2011, 02:02 AM   #5 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 36
svenJ is on a distinguished road
Default

Quote:
Originally Posted by BinHex View Post
Do this…

nieuwsDetailView.h
@interface nieuwsDetailView: UIViewController

@property(retain, nonatomic) NSString* theTestString;


theTableViewController.m

/* if a nib file */
nieuwsDetailView *NieuwsDetailView = [[nieuwsDetailView alloc] initWithNibName:@"NieuwsDetailView" bundle:nil];

/* pass the testString value to theTestString property in the detail view */
NieuwsDetailView.theTestString = testString;


[self.navigationController pushViewController:NieuwsDetailView animated:YES];
[NieuwsDetailView release];
Thanks a lot! Works great! :-)
svenJ is offline   Reply With Quote
Old 10-19-2011, 08:35 AM   #6 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 36
svenJ is on a distinguished road
Default

I'm pretty much stuck again..

I successfully created the detailedNewsView. And I've also added a Next/Prev button at the top-right such as in Apple's mail app. But again I'm not quite sure how to get the right information passed through.

Sure I can add more variables (per the next and previous item) when a user tabs an item in the UITableView but if he or she then proceeds clicking 'previous' it will eventually get an error. Also I don't think this it THE way.

What is the most obvious way to do this? Send data from the UITableView or recollect information from the RSS Feed (I'm using TouchXML) for the previous and next item?

Once again thanks in advance!
svenJ is offline   Reply With Quote
Reply

Bookmarks

Tags
detailview, didselectrowatindexpath, news, tableview

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: 401
16 members and 385 guests
13dario13, 7twenty7, buggen, eski, EvilElf, glenn_sayers, LunarMoon, morterbaher, n00b, pbart, QuantumDoja, sacha1996, Sami Gh, UMAD, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,673
Threads: 94,122
Posts: 402,906
Top Poster: BrianSlick (7,990)
Welcome to our newest member, morterbaher
Powered by vBadvanced CMPS v3.1.0

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