didSelectRowAtIndexPath connects to another table view in window-based app.

Hi all,
I am new to iPhone programming, i have started my first application in windows-based application for iPhone OS. In this i am loading UITableView for displaying RSS feeds, when the RSS feeds are loaded in the table cell, i click on the table cells to move to another table view for reading detailed description of RSS feeds.

So in Window-based application can u help me in generating another tableview?

i have created a another view using UIViewController subclass but the didSelectRowAtIndexPath does not redirect to that view. So whether i need to use some other subclass files for connecting to another view ?

Thanks for any help!

Sathiya

iMac, Mac OS X (10.5.6)

Posted on Jun 1, 2009 12:14 AM

Reply
17 replies

Jun 1, 2009 3:36 AM in response to Sathiya

Can we see your didSelectRowAtIndexPath method? Please also explain what you mean by "windows-based"?

To post the code for your method, just enclose it in two
tags like this:

Paste your code here.
{code}

Note that both the opening and closing tags are the same (not like xml). You can see how your post will appear by clicking on the Preview tab above the Reply editor panel.

Jun 1, 2009 10:24 PM in response to RayNewbie

thanks for your reply!

I mean that "windows-based" is an application template in XCODE. I have started my application with this template.
Here goes my code,


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{


DisclosureDetailButton *detButton = [[DisclosureDetailButton alloc]init];
//[self.vwController pushViewController:detButton animated:YES];
[self.vwController show];
[detButton release];

}


when i use these lines of code the table is not redirected to another view , moreover i get a warning that "-show" method is not supported. or if use the commented line code " [self.vwController pushViewController:detButton animated:YES]; " means i get another warning as "-pushViewController" method does not respond.

so i need your help in this, while clicking on the cells i have to move to detailed description of that RSS content in a next table View.

please let me know if i need to provide more details.

Jun 2, 2009 12:55 AM in response to Sathiya

Ok, I more or less get the picture.

The code seems to reflect a general misunderstanding of the objects and methods required for this kind of transition. Wherever you found that code, please never go back there. Here are some of the serious problems:

1) The DisclosureDetailButton class would need to be a subclass of UIViewController for the code to make any sense. If it is such a subclass, the name is unacceptably misleading. It seems more likely the result of some confusion with UITableViewCellAccessoryDetailDisclosureButton, which is a standard table view cell control.
2) The line commented out, which is trying to push detButton onto a controller stack, is probably failing because vwController is not a UINavigationController. If vwController is actually a navigation controller the nomenclature is, again, totally unacceptable. The important point is that you need a navigation controller to do a transition of this kind.
3) 'show' isn't a method of UIViewController or UIView. If there were such a method and it was meant to display a view (as in some other API's), it wouldn't be used in a navigation transition. Atm the only show method I know of is in the UIAlertView class, so I'm curious as to how it got into your code.

I'm not sure it will help to get this one method straightened out in isolation from the rest of your program, because it depends on a lot of structure you may not have. Do you already have a working table view? Do you in fact have a navigation controller? Do you have any view controllers created in code or in IB that are ready to be pushed onto a nav stack? If you have some of that structure we can try and work with it, but if the rest of your table view code is anything like today's method it could be a long summer.

Luckily, earlier today I posted some code in another thread that shows all the methods you need to transition from a table view selection to the corresponding detail view using a navigation controller: [http://discussions.apple.com/thread.jspa?messageID=9549416#9549416]. That code does a little more than you may want right now, but I think it's a lot simpler than any of the sample apps I could refer you to. Why not take a look at it, and maybe even see if you can integrate it into your app? The code is working, tested code, so about the only way you can crash it is with the wrong IB connections.

In any case, I'd like you to get a good book on the iPhone SDK. The one I recommend is +Beginning iPhone Development: Exploring the iPhone SDK+ by Mark and LaMarche. Everything you want to know about table views and nav controllers is explained very clearly with some excellent, fun projects in Chapters 8-9. I think you should start closer to the beginning, though. Chapter 6 is about the basics of view transitions. Don't skip that Chapter!

\- Ray

Jun 2, 2009 2:35 AM in response to RayNewbie

thanks again for making me clearer. I have already gone through the book u referred Mr.RayNewbie.

Now i will make u more clearer where i have struck. The following code is the AppDelegate.h file,


#import <UIKit/UIKit.h>
#define kNameValueTag 1
#define kColorValueTag 2
@interface GVA_iPhoneAppDelegate : NSObject <UIApplicationDelegate,UITableViewDataSource,UITableViewDelegate> {
UIWindow *window;

IBOutlet UIViewController *vwController;
//NSArray *listData;
UITableView *myTable;


UIActivityIndicatorView *activityIndicator;
CGSize cellSize;
NSXMLParser *rssParser;
NSMutableArray *stories;
NSMutableDictionary *item;
NSString *currentElement;
NSMutableString *currentTitle, *currentDate, *currentSummary, *currentLink, *currentImage;

}
//@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic,retain) UIViewController *vwController;
@end


and here goes the appdelegate.m file,


#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "GVA_iPhoneAppDelegate.h"
#import "DisclosureDetailButton.h"
@implementation GVA_iPhoneAppDelegate
@synthesize slideMenu, screenLabel, vwController;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after application launch
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;
myTable = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 120.0, 320.0, 310.0)];
myTable.dataSource = self;
myTable.delegate = self;
myTable.rowHeight = 120;

[window addSubview:myTable];
[window addSubview:vwController.view];
[window makeKeyAndVisible];
if([stories count] == 0) {
//NSString *pah = @"http://rss.feedsportal.com/c/865/f/11107/index.rss ";
[self parseXMLFileAtURL:@"http://rss.feedsportal.com/c/865/f/11107/index.rss "];
}
cellSize = CGSizeMake([myTable bounds].size.width,60);

}
- (void)parseXMLFileAtURL:(NSString *)URL {
stories = [[NSMutableArray alloc] init];

//you must then convert the path to a proper NSURL or it won't work
NSURL *xmlURL = [NSURL URLWithString:URL];

// here, for some reason you have to use NSClassFromString when trying to alloc NSXMLParser, otherwise you will get an object not found error
// this may be necessary only for the toolchain
rssParser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL];

// Set self as the delegate of the parser so that it will receive the parser delegate methods callbacks.
[rssParser setDelegate:self];

// Depending on the XML document you're parsing, you may want to enable these features of NSXMLParser.
[rssParser setShouldProcessNamespaces:NO];
[rssParser setShouldReportNamespacePrefixes:NO];
[rssParser setShouldResolveExternalEntities:NO];

[rssParser parse];
}
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError {
NSString * errorString = [NSString stringWithFormat:@"Unable to download story feed from web site (Error code %i )", [parseError code]];
NSLog(@"error parsing XML: %@", errorString);

UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Error loading content" message:errorString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlert show];
}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
//NSLog(@"found this element: %@", elementName);
currentElement = [elementName copy];

if ([elementName isEqualToString:@"item"]) {
// clear out our story item caches...
item = [[NSMutableDictionary alloc] init];
currentTitle = [[NSMutableString alloc] init];
currentDate = [[NSMutableString alloc] init];
currentSummary = [[NSMutableString alloc] init];
currentLink = [[NSMutableString alloc] init];
currentImage = [[NSMutableString alloc] init];
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{

//NSLog(@"ended element: %@", elementName);
if ([elementName isEqualToString:@"item"]) {
// save values to an item, then store that item into the array...
[item setObject:currentTitle forKey:@"title"];
[item setObject:currentImage forKey:@"link"];
[item setObject:currentSummary forKey:@"summary"];
[item setObject:currentDate forKey:@"date"];

[stories addObject:[item copy]];
NSLog(@"adding story: %@", currentTitle);
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
//NSLog(@"found characters: %@", string);
// save the characters for the current item...
if ([currentElement isEqualToString:@"title"]) {
[currentTitle appendString:string];
} else if ([currentElement isEqualToString:@"link"]) {
[currentImage appendString:string];
} else if ([currentElement isEqualToString:@"description"]) {
[currentSummary appendString:string];
} else if ([currentElement isEqualToString:@"pubDate"]) {
[currentDate appendString:string];
}

}
- (void)parserDidEndDocument:(NSXMLParser *)parser {

[activityIndicator stopAnimating];
[activityIndicator removeFromSuperview];

NSLog(@"all done!");
NSLog(@"stories array has %d items", [stories count]);
[myTable reloadData];
}
- (void)dealloc {
[window release];
[myTable release];
[vwController release];
[super dealloc];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [stories count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GVAiPhone"];
if (cell == nil) {
//CGRect cellFrame = CGRectMake(0, 0, 300, 65);
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"GVAiPhone"] autorelease];
//cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
//cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow_icon.png"]];
CGRect nameValueRect = CGRectMake(5, 5, 275, 35);
UILabel *nameValue = [[UILabel alloc] initWithFrame:nameValueRect];
nameValue.tag = kNameValueTag;
nameValue.font = [UIFont fontWithName:@"Arial" size:15.0];
nameValue.lineBreakMode = UILineBreakModeWordWrap;
nameValue.numberOfLines = 2;
[cell.contentView addSubview:nameValue];
[nameValue release];

CGRect colorValueRect = CGRectMake(5, 38, 275, 65);
UILabel *colorValue = [[UILabel alloc] initWithFrame:colorValueRect];
colorValue.tag = kColorValueTag;
colorValue.font = [UIFont fontWithName:@"Arial" size:11.0];
colorValue.textColor = [UIColor colorWithRed:130.0/255.0 green:135.0/255.0 blue:139.0/255.0 alpha:1.0];
colorValue.lineBreakMode = UILineBreakModeWordWrap;
colorValue.textAlignment = UITextAlignmentLeft;
colorValue.numberOfLines = 6;
[cell.contentView addSubview:colorValue];
[colorValue release];
}
// Set up the cell
//cell.text = [theSimpsons objectAtIndex:indexPath.row];
cell.hidesAccessoryWhenEditing = YES;

NSUInteger storyIndex = [indexPath row];

NSDictionary *rowData = [stories objectAtIndex:storyIndex];
UILabel *name = (UILabel *)[cell.contentView viewWithTag:kNameValueTag];
name.text = [rowData objectForKey:@"title"];
//name.lineBreakMode;

//UIImage *image =[UIImage imageNamed: currentImage];imageWithContentsOfFile
//image.size.width = 50;
//iimage.size.height = 50;
//cell.image = [UIImage imageNamed:currentImage];
cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow_icon.png"]];


UILabel *color = (UILabel *)[cell.contentView viewWithTag:kColorValueTag];
color.text = [rowData objectForKey:@"summary"];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DisclosureDetailButton *detButton = [[DisclosureDetailButton alloc]init];
//[self.vwController pushViewController:detButton animated:YES];
[self.vwController show];
[detButton release];

}
@end


with this code in Windows-based application, i parse the xml feeds from the link and display the data in a UITableView. For the detailed description of the particular data, i click on the cells of the table that should lead to an another view through the "didSelectRowAtIndexPath" method.

moreover you can find from the code that i don't use any Nib file. So can u please help me in sorting out that what subclass files (eg:UIViewController subclass) can i add to these base class file i.e. appDelegate.h file ?

so please provide a more clearer idea.

Thanks for your reply
-Sathiya

Jun 3, 2009 1:37 AM in response to Sathiya


// GVA_iPhoneAppDelegate.h
#import <UIKit/UIKit.h>
@class RootViewController;
@interface GVA_iPhoneAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
UINavigationController *navController;
RootViewController *rootViewController;
}
@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) UINavigationController *navController;
@property (nonatomic,retain) RootViewController *rootViewController;
@end
// GVA_iPhoneAppDelegate.m
#import "GVA_iPhoneAppDelegate.h"
#import "RootViewController.h"
@implementation GVA_iPhoneAppDelegate
@synthesize window, navController, rootViewController;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after application launch
UIWindow *aWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window = aWindow;
[aWindow release];

RootViewController *aController = [[RootViewController alloc] init];
self.rootViewController = aController;
[aController release];

UINavigationController *aNavController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
self.navController = aNavController;
[aNavController release];
[window addSubview:navController.view];
[window makeKeyAndVisible];
}
- (void)dealloc {
[rootViewController release];
[navController release];
[window release];
[super dealloc];
}
@end
// RootViewController.h
#import <UIKit/UIKit.h>
#define kNameValueTag 1
#define kColorValueTag 2
@class DetailViewController;
@interface RootViewController : UIViewController <UITableViewDataSource, UITableViewDelegate> {
DetailViewController *detailViewController;
//NSArray *listData;
UITableView *myTable;

UIActivityIndicatorView *activityIndicator;
CGSize cellSize;
NSXMLParser *rssParser;
NSMutableArray *stories;
NSMutableDictionary *item;
NSString *currentElement;
NSMutableString *currentTitle, *currentDate, *currentSummary, *currentLink, *currentImage;
}
@property (nonatomic, retain) UITableView *myTable;
@property (nonatomic,retain) DetailViewController *detailViewController;
@end
// RootViewController.m
#import "RootViewController.h"
#import "DetailViewController.h"
@implementation RootViewController
@synthesize detailViewController, myTable;
- (void)parseXMLFileAtURL:(NSString *)URL {
stories = [[NSMutableArray alloc] init];

//you must then convert the path to a proper NSURL or it won't work
NSURL *xmlURL = [NSURL URLWithString:URL];

// here, for some reason you have to use NSClassFromString when trying to alloc NSXMLParser, otherwise you will get an object not found error
// this may be necessary only for the toolchain
rssParser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL];

// Set self as the delegate of the parser so that it will receive the parser delegate methods callbacks.
[rssParser setDelegate:self];

// Depending on the XML document you're parsing, you may want to enable these features of NSXMLParser.
[rssParser setShouldProcessNamespaces:NO];
[rssParser setShouldReportNamespacePrefixes:NO];
[rssParser setShouldResolveExternalEntities:NO];

[rssParser parse];
}
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError {
NSString * errorString = [NSString stringWithFormat:@"Unable to download story feed from web site (Error code %i )", [parseError code]];
NSLog(@"error parsing XML: %@", errorString);

UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Error loading content" message:errorString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlert show];
}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
//NSLog(@"found this element: %@", elementName);
currentElement = [elementName copy];

if ([elementName isEqualToString:@"item"]) {
// clear out our story item caches...
item = [[NSMutableDictionary alloc] init];
currentTitle = [[NSMutableString alloc] init];
currentDate = [[NSMutableString alloc] init];
currentSummary = [[NSMutableString alloc] init];
currentLink = [[NSMutableString alloc] init];
currentImage = [[NSMutableString alloc] init];
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{

//NSLog(@"ended element: %@", elementName);
if ([elementName isEqualToString:@"item"]) {
// save values to an item, then store that item into the array...
[item setObject:currentTitle forKey:@"title"];
[item setObject:currentImage forKey:@"link"];
[item setObject:currentSummary forKey:@"summary"];
[item setObject:currentDate forKey:@"date"];

[stories addObject:[item copy]];
NSLog(@"adding story: %@", currentTitle);
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
//NSLog(@"found characters: %@", string);
// save the characters for the current item...
if ([currentElement isEqualToString:@"title"]) {
[currentTitle appendString:string];
} else if ([currentElement isEqualToString:@"link"]) {
[currentImage appendString:string];
} else if ([currentElement isEqualToString:@"description"]) {
[currentSummary appendString:string];
} else if ([currentElement isEqualToString:@"pubDate"]) {
[currentDate appendString:string];
}

}
- (void)parserDidEndDocument:(NSXMLParser *)parser {

[activityIndicator stopAnimating];
[activityIndicator removeFromSuperview];

NSLog(@"all done!");
NSLog(@"stories array has %d items", [stories count]);
[myTable reloadData];
}
- (void)loadView {
self.title = @"GVA_iPhone";
CGRect frame = [[UIScreen mainScreen] bounds];
UIView *aView = [[UIView alloc] initWithFrame:frame];
aView.backgroundColor = [UIColor grayColor];
self.view = aView;
[aView release];

UITableView *aTableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 416.0)];
aTableView.dataSource = self;
aTableView.delegate = self;
aTableView.rowHeight = 120;
self.myTable = aTableView;
[aTableView release];
[self.view addSubview:myTable];

if([stories count] == 0) {
//NSString *pah = @"http://rss.feedsportal.com/c/865/f/11107/index.rss ";
[self parseXMLFileAtURL:@"http://rss.feedsportal.com/c/865/f/11107/index.rss "];
}
cellSize = CGSizeMake([myTable bounds].size.width,60);
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
// Release anything that's not essential, such as cached data
}
- (void)dealloc {
[myTable release];
[detailViewController release];
[super dealloc];
}
#pragma mark -
#pragma mark Table View Data Source Methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [stories count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GVAiPhone"];
if (cell == nil) {
//CGRect cellFrame = CGRectMake(0, 0, 300, 65);
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"GVAiPhone"] autorelease];
//cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
//cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow_icon.png"]];
CGRect nameValueRect = CGRectMake(5, 5, 275, 35);
UILabel *nameValue = [[UILabel alloc] initWithFrame:nameValueRect];
nameValue.tag = kNameValueTag;
nameValue.font = [UIFont fontWithName:@"Arial" size:15.0];
nameValue.lineBreakMode = UILineBreakModeWordWrap;
nameValue.numberOfLines = 2;
[cell.contentView addSubview:nameValue];
[nameValue release];

CGRect colorValueRect = CGRectMake(5, 38, 275, 65);
UILabel *colorValue = [[UILabel alloc] initWithFrame:colorValueRect];
colorValue.tag = kColorValueTag;
colorValue.font = [UIFont fontWithName:@"Arial" size:11.0];
colorValue.textColor = [UIColor colorWithRed:130.0/255.0 green:135.0/255.0 blue:139.0/255.0 alpha:1.0];
colorValue.lineBreakMode = UILineBreakModeWordWrap;
colorValue.textAlignment = UITextAlignmentLeft;
colorValue.numberOfLines = 6;
[cell.contentView addSubview:colorValue];
[colorValue release];
}
// Set up the cell
//cell.text = [theSimpsons objectAtIndex:indexPath.row];
cell.hidesAccessoryWhenEditing = YES;

NSUInteger storyIndex = [indexPath row];

NSDictionary *rowData = [stories objectAtIndex:storyIndex];
UILabel *name = (UILabel *)[cell.contentView viewWithTag:kNameValueTag];
name.text = [rowData objectForKey:@"title"];
//name.lineBreakMode;

//UIImage *image =[UIImage imageNamed: currentImage];imageWithContentsOfFile
//image.size.width = 50;
//iimage.size.height = 50;
//cell.image = [UIImage imageNamed:currentImage];
cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow_icon.png"]];
UILabel *color = (UILabel *)[cell.contentView viewWithTag:kColorValueTag];
color.text = [rowData objectForKey:@"summary"];
return cell;
}
#pragma mark -
#pragma mark Table View Delegate Methods
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (self.detailViewController == nil) {
DetailViewController *aViewController = [[DetailViewController alloc] init];
self.detailViewController = aViewController;
[aViewController release];
}
detailViewController.currentLink = [[stories objectAtIndex:indexPath.row] objectForKey:@"link"];
[self.navigationController pushViewController:detailViewController animated:YES];
}
@end
// DetailViewController.h
#import <UIKit/UIKit.h>
@interface DetailViewController : UIViewController {
NSString *currentLink;
}
@property (nonatomic, copy) NSString *currentLink;
@end
// DetailViewController.m
#import "DetailViewController.h"
@implementation DetailViewController
@synthesize currentLink;
- (void)viewWillAppear:(BOOL)animated {
NSLog(@"viewWillAppear: currentLink=%@", currentLink);
}
// Implement loadView to create a view hierarchy programmatically.
- (void)loadView {
self.title = @"Detail View";
CGRect frame = [[UIScreen mainScreen] bounds];
UIView *aView = [[UIView alloc] initWithFrame:frame];
aView.backgroundColor = [UIColor grayColor];
self.view = aView;
[aView release];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
// Release anything that's not essential, such as cached data
}
- (void)dealloc {
[currentLink release];
[super dealloc];
}
@end

Jun 4, 2009 5:03 AM in response to RayNewbie

Thanks Mr.RayNewbie. I am trying with your solution i have reached to some extent. Thanks for your help.

Still i have an issue, that in the navigation bar can i replace the full bar with an logo or an image? if so whether i have to use an .Nib file? please reply. It would be much better to solve my question.

Thanks a lot.

Sathiya

Jun 4, 2009 8:04 PM in response to Sathiya

If I understood your original question and the apparent purpose of your code, the files I wrote for you should do exactly what you wanted. My last response consisted of 6 files of working, tested source code which is running as an almost complete app at this end. To help you see this point, if I cleaned up some of the memory management problems in your XML code and then added a UIWebView to the detail view, the app on my system might be ready to submit to the store.

If you aren't getting the results you wanted from the files I gave you, I suggest you drop all 6 files into the Window-Based Application template to verify the code is correct, and to see how it operates. Since it was necessary to restructure your app in order to use a navigation controller correctly, I recommend integrating any additional code you have into the structure I provided instead of vice-versa.
Still i have an issue

Rather than have me finish your entire application in this thread, I would recommend starting a new thread for any additional issue unrelated to the current topic. For example the Subject line of your next question might be "How can I cover a nav bar with an image"? A new thread has the advantage of encouraging other developer's to contribute.

\- Ray

Jun 5, 2009 5:06 AM in response to Sathiya

Sathiya wrote:
the detiled page doesn't display any RSS data.

It's usually helpful to accurately state your request in the Subject line of your thread. In this case for example, "Want volunteer to complete my app" might have described your expectation better than "didSelectRowAtIndexPath connects to another table view ...".

Although I didn't code the detail view controller, note that I showed you how to import current selection data by setting an ivar and overriding viewWillAppear:

@implementation RootViewController
@synthesize detailViewController, myTable;
// ...
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
// ...
detailViewController.currentLink = [[stories objectAtIndex:indexPath.row] objectForKey:@"link"];
@implementation DetailViewController
@synthesize currentLink;
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated]; // this line should be added, btw
NSLog(@"viewWillAppear: currentLink=%@", currentLink);
}

Jun 5, 2009 7:16 AM in response to RayNewbie

Ray,
Thanks for the link to your code. I will examine that closely as I am having trouble with my table view.

I am using the book you mention as a guide, and frankly, am not finding those chapters as helpful as you might think. For one, my table view is part of a view, and as such I cannot use a UITableViewController. This assumption at the beginning of Chapter 9 makes it difficult for me to see how to apply the ideas to my code. And I feel like the discussion explaining how a navigation controller works is extremely weak.

If you have any pointers to any other references that have information about navigation controllers and table views, that would be much appreciated.

Thank you!

Elisabeth

Jun 8, 2009 6:37 AM in response to RayNewbie

Hi..,

Again there is problem in displaying the data in table cells. The data is Static in DetailviewController. the cell.text displays the same data when i click the different links. the data is passed correctly from root viewcontroller to detailviewcontroller because i can check this from UIAlertView. but the same data that i receive inside the alert message is not shown in table cell.

Please help me in solving out.
-sathiya

Jun 9, 2009 4:03 AM in response to RayNewbie

I have to pass the CurrentTitle, CurrentImage and CurrentSummary from RootViewController to DetailViewController. but As per the code given by you, i can pass only one value and not all the three values together.

detailViewController.currentSummary = [[stories objectAtIndex:indexPath.row] objectForKey:@"summary"];

how can i pass all the three values in this? please suggest me.
-sathiya

Jun 9, 2009 9:21 PM in response to Sathiya

Is there some reason you don't want to duplicate some of the code I wrote for you to make similar lines for three additional variables?

@implementation RootViewController
@synthesize detailViewController, myTable;
// ...
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// ...
detailViewController.currentTitle = [[stories objectAtIndex:indexPath.row] objectForKey:@"title"];
detailViewController.currentImage = [[stories objectAtIndex:indexPath.row] objectForKey:@"link"];
detailViewController.currentSummary = [[stories objectAtIndex:indexPath.row] objectForKey:@"description"];
detailViewController.currentDate = [[stories objectAtIndex:indexPath.row] objectForKey:@"pubDate"];
// ...
}

@implementation DetailViewController
@synthesize currentTitle, currentImage, currentSummary, currentDate, detailTableView;
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
// all data required by tableView:cellForRowAtIndexPath: should now be stored in ivars of this class
[detailTableView reloadData];
}

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

didSelectRowAtIndexPath connects to another table view in window-based app.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.