mwfeedpaser detailview - xcode

I just started using xcode and OBJ-c this year.
I am using mwfeedparser for a app I'm making but would like to change the look of the detailview.
right now i'm using the demo app that came with mwfeedparser to change the detail view.
i would like the detail view to have labels instead of being a tableview
i have changed this code
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailViewController *detail = [[DetailViewController alloc] initWithNibName:#"DetailView" bundle:nil];
detail.item = (MWFeedItem *)[itemsToDisplay objectAtIndex:indexPath.row];
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detail animated:YES];
// Deselect
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}
when i run the code the detailview doesn't even come up. am I doing something wrong?
thanks for your help.
btw when i do get this done I'll put it up on github incase anybody else needs it

enter code hereself.parsedItems = [[NSMutableArray alloc] init];
- (void)feedParser:(MWFeedParser *)parser didParseFeedItem:(MWFeedItem *)item{
if (item) {
[self.parsedItems addObject:item];
}
}
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
DetailViewController *detail = [[DetailViewController alloc] initWithNibName:#"DetailView" bundle:nil];
detail.item = [self.parsedItems objectAtIndex:indexPath.row];
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detail animated:YES];
}

Related

How to push new view from TableViewCell?

In my app I am trying to navigate to a new View from a TableViewCell, But i dont know how. Could you help guys? I am using Xcode 4.6. and .xib, no storyboard. I am very new to coding so please explain it as simple as possible! Here is what i have tried, please correct me:
- (void)viewDidLoad
{
tableData = [[NSArray alloc] initWithObjects:#"aaoversikt1", #"Paul", #"George", #"Ringo", nil];
[super viewDidLoad];
UILabel *nav_title1 = [[UILabel alloc] initWithFrame:CGRectMake(60, 10, 220, 25)];
nav_title1.font = [UIFont fontWithName:#"Arial-BoldMT" size:18];
nav_title1.textColor = [UIColor whiteColor];
nav_title1.adjustsFontSizeToFitWidth = NO;
nav_title1.textAlignment = NSTextAlignmentCenter;
nav_title1.text = #"Ă…lesund";
nav_title1.backgroundColor = [UIColor clearColor];
self.navigationItem.titleView = nav_title1;
}
#pragma mark - TableView Data Source methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection: (NSInteger)section;
{
return [tableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
UITableViewCell *cell = nil;
static NSString *CellIdentifier = #"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
return cell;
}
#pragma mark - TableView Delegate methods
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
AAOversiktViewController *aaoversikt1 = [[AAOversiktViewController alloc] initWithNibName:#"AAOversiktViewController" bundle:nil];
[self.navigationController pushViewController:aaoversikt1 animated:YES];
}
Thank You!
From first glance I would say that the problem lies within your [self.navigationController pushViewController] method. Have you initiated a navigation controller in your app either in the app delegate or root view controller?
If not i would recommend:
[self presentViewController:aaoversik1 animated:YES completion:NULL];
If you are wanting to push through the navigation stack so that you have a back button then I would look at implementing a UINaviationController.
Otherwise you can create a custom back button and use the same method in this post to present the root view controller (not totally recomended as using UINavigationController is much cleaner).
Let me know if this has been of any help, T

Xcode: How to switch to another window using TableView?

the error ---> when i click the name the application crashes...
rectification---> when i click the name in table it should jump to another view...
my code is
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[ListArr objectAtIndex:indexPath.row];
ListData *oList = [[ListData alloc] initWithNibName:#"ListData" bundle:nil];
NSString *psCatId = [NSString stringWithFormat:#"%d",indexPath.row+1];
oList.psId = psCatId;
[self presentModalViewController:oList animated:YES];
[oList release];
}

How to change it back from activity indicator to disclosure in UITableViewCell after pushViewController

How to change it back from activity indicator to disclosure ??
the problem is:
When i didSelectRow, i made disclosure to activity indicator because it will load some picture for the next view controller and It's worked, but i dont have any luck to change it back to disclosure after pushViewController. i already tried to reload the table from the 2ndViewController but it's crashed.
So anybody have a solution for this problem..
Thanks in advance
This is my code in didSelectRow :
-(void)threadStartAnimating:(id)data
{
[activityView startAnimating];
[self.navigationController pushViewController:bdvController animated:YES];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[cell setAccessoryView:activityView];
[NSThread detachNewThreadSelector:#selector(threadStartAnimating:) toTarget:self withObject:nil];
// Navigation logic -- create and push a new view controller
if(bdvController == nil)
bdvController = [[DetailViewController alloc] initWithNibName:#"DetailViewController" bundle:[NSBundle mainBundle]];
AppRecord *appRecord = [self.entries objectAtIndex:indexPath.row];
bdvController.appsRecord = appRecord;
bdvController.HeaderText.text = appRecord.appName;
bdvController.title = appRecord.artist;
[bdvController.tableView reloadData];
}
The best way is to set pointer nil to the accessoryView, example:
cell.accessoryView = nil;
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.selectionStyle = UITableViewCellSelectionStyleGray;
In my code these operations work fine.

How to update detailView using a popover

I have a TableViewController which is represented by a popover, that is displayed by selecting a bar button item on a tool bar. I'm having a problem however that when I select an item from the table in the popover it doesn't update the view (affirmaPDFViewController)
Here is the DidSelectRowAtIndex method for my PDFTableController (the popover):
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
affirmaPDFViewController.detailItem = [NSString stringWithFormat:#"%#", [listOfPDF objectAtIndex:indexPath.row]];
affirmaPDFViewController.i = indexPath.row;
NSLog(#"%d", indexPath.row);
NSLog(#"%#", [listOfPDF objectAtIndex:indexPath.row]);
NSLog(#"%d", affirmaPDFViewController.i);
NSLog(#"%#", affirmaPDFViewController.detailItem);
}
Here the indexPath.row and the objectAtIndex:indexPath.row all return the correct values. However when I assign the variables from affirmaPDFViewController to those values they just return 0 and null.
I've been told it is because I haven't created an instance of affirmaPDFViewController. However, I'm not sure how to create such an instance. What code would I put in this method to get this to work?
Thanks in advance!
- (void)viewDidLoad
{
[super viewDidLoad];
affirmaPDFViewController = [[NameOfClassGoesHere alloc] initWithNibName:#"NibNameGoesHere" bundle:nil];
}

How to update detailViewController.detailItem from multi-level nav in rootViewController

this is my first post so please be gently.
I am using the basic Split View-based application within xcode, but have edited it so that the rootViewController does not simply update the detailViewController, but instead pushes a new UITableViewController (taskViewController) onto the navigation stack.
My problem is, that nothing happens when I now call the following from my taskViewController:
detailViewController.detailItem = [NSString stringWithFormat:#"Row %d", indexPath.row];
If I call this from rootViewController, instead of pushing a new UITableView onto the stack, it works.
Here is my code from rootViewController when a cell is selected:
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
TaskViewController *taskViewController = [[TaskViewController alloc] init];
taskViewController.title = [NSString stringWithFormat:#"Unit %d",indexPath.row];
[self.navigationController pushViewController:taskViewController animated:YES];
[taskViewController release];
}
Have I done something wrong here? Am I using the navigation controller correctly within the rootViewController of the UISplitViewController?
Your rootViewController can access detailViewController because it has a referance to it. if you push a new controller onto the nav stack, then its not automatically going to know about DetailViewController.
Have you NSLog'd detailViewController in your taskVC to see if it has a pointer?
You would typically set this when you are creating it like this:
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
TaskViewController *taskViewController = [[TaskViewController alloc] init];
taskViewController.title = [NSString stringWithFormat:#"Unit %d",indexPath.row];
taskViewController.detailViewController = self.detailViewController;
[self.navigationController pushViewController:taskViewController animated:YES];
[taskViewController release];
}

Resources