Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Oct 29, 2012, 07:58 AM   #51
RagingGoat
Thread Starter
macrumors regular
 
Join Date: Jun 2010
I got the table view to populate by taking this code out of KFBAppDelegate and putting it into the code for the button in KFBViewController.
Code:
ListViewController *lvc = [[ListViewController alloc]initWithStyle:UITableViewStylePlain];
    WebViewController *wvc = [[WebViewController alloc]init];
    [lvc setWebViewController:wvc];
The problem now is that when I select a row in the table view it doesn't go to the web view. I'm going to look at it to see if I can figure it out but if anyone has any suggestions, I would appreciate it. You guys have been awesome so far!

I'll be back when I either figure it out or need more help.
RagingGoat is offline   0 Reply With Quote
Old Oct 29, 2012, 08:57 AM   #52
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by RagingGoat View Post
I got the table view to populate by taking this code out of KFBAppDelegate and putting it into the code for the button in KFBViewController.
Code:
ListViewController *lvc = [[ListViewController alloc]initWithStyle:UITableViewStylePlain];
    WebViewController *wvc = [[WebViewController alloc]init];
    [lvc setWebViewController:wvc];
That's good to hear. What debugging led you to this solution?

Quote:
The problem now is that when I select a row in the table view it doesn't go to the web view
What delegate method is called when you select a row in a table and what debugging have you done in relation to it?
__________________
dejo is offline   0 Reply With Quote
Old Oct 29, 2012, 10:13 AM   #53
RagingGoat
Thread Starter
macrumors regular
 
Join Date: Jun 2010
Here is the code in ListViewController that uses the web view:

Code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Push the web view controller onto the navigation stack - this implicitly creates the web view controller's view the first time through
    [[self navigationController]pushViewController:webViewController animated:YES];
    
    // Grab the selected item
    RSSItem *entry = [[channel items]objectAtIndex:[indexPath row]];
    
    // Construct a URL with the link string of the item
    NSURL *url = [NSURL URLWithString:[entry link]];
    
    // Construct a request object with that URL
    NSURLRequest *req = [NSURLRequest requestWithURL:url];
    
    // Load the request into the web view
    [[webViewController webView]loadRequest:req];
    
    // Set the title of the web view controller's navigation item
    [[webViewController navigationItem]setTitle:[entry title]];
}
I haven't done any debugging yet because I haven't had a chance to really look at it further since I got the other part working. I just wanted to give an update to everyone who has been helping.

As far as the debugging that led me to fix the table view, it was a combination of adding break points, adding the NSLog statement in order to see what the count was, and what chown33 mentioned about some things in the AppDelegate file.
RagingGoat is offline   0 Reply With Quote
Old Oct 29, 2012, 10:24 AM   #54
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by RagingGoat View Post
As far as the debugging that led me to fix the table view, it was a combination of adding break points, adding the NSLog statement in order to see what the count was, and what chown33 mentioned about some things in the AppDelegate file.
Don't forget to also fix your linked images bug I mentioned earlier.
__________________
dejo is offline   0 Reply With Quote
Old Oct 29, 2012, 11:36 AM   #55
RagingGoat
Thread Starter
macrumors regular
 
Join Date: Jun 2010
Quote:
Originally Posted by dejo View Post
Don't forget to also fix your linked images bug I mentioned earlier.
Thanks for reminding me! I meant to ask you about that. How do you add them to the project? I thought you just copied them into xcode but apprently I was wrong.
RagingGoat is offline   0 Reply With Quote
Old Oct 29, 2012, 12:23 PM   #56
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by RagingGoat View Post
Thanks for reminding me! I meant to ask you about that. How do you add them to the project? I thought you just copied them into xcode but apprently I was wrong.
Make sure you have checked the following option when adding those files:



P.S. Any progress on your latest bug?
__________________
dejo is offline   0 Reply With Quote
Old Oct 29, 2012, 12:35 PM   #57
RagingGoat
Thread Starter
macrumors regular
 
Join Date: Jun 2010
Thanks and no I haven't been able to dive into the new bug yet.
RagingGoat is offline   0 Reply With Quote
Old Oct 29, 2012, 01:12 PM   #58
RagingGoat
Thread Starter
macrumors regular
 
Join Date: Jun 2010
I did put a break point here and the application stopped running when I selected a row in the table view.

Code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Push the web view controller onto the navigation stack - this implicitly creates the web view controller's view the first time through
    [[self navigationController]pushViewController:webViewController animated:YES];
    
    // Grab the selected item
    RSSItem *entry = [[channel items]objectAtIndex:[indexPath row]];
    
    // Construct a URL with the link string of the item
    NSURL *url = [NSURL URLWithString:[entry link]];
    
    // Construct a request object with that URL
    NSURLRequest *req = [NSURLRequest requestWithURL:url];
    
    // Load the request into the web view
    [[webViewController webView]loadRequest:req];
    
    // Set the title of the web view controller's navigation item
    [[webViewController navigationItem]setTitle:[entry title]];
}
RagingGoat is offline   0 Reply With Quote
Old Oct 29, 2012, 01:19 PM   #59
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by RagingGoat View Post
I did put a break point here and the application stopped running when I selected a row in the table view.
So, your delegate method is being called. Good. Now it's time to make some predictions and do some debugging (NSLogs, debug console commands, code step-through, etc.) to confirm or debunk those predictions. Try and figure out what might cause your WebViewController not to appear.

P.S. I would suggest waiting to push the new controller until you've done the setup. Just seems like a more logical progression of steps.
__________________
dejo is offline   0 Reply With Quote
Old Oct 29, 2012, 02:21 PM   #60
RagingGoat
Thread Starter
macrumors regular
 
Join Date: Jun 2010
I added some NSLog statements to that delegate method to verify that it is getting the URL when a row is selected. It is getting the URL. Here are the results:

2012-10-29 15:19:26.539 KFBNewsroom[3697:c07] Link: http://kyfbnewsroom.com/2012/10/22/r...votes-matter-2
2012-10-29 15:19:26.540 KFBNewsroom[3697:c07] URL: http://kyfbnewsroom.com/2012/10/22/r...votes-matter-2
2012-10-29 15:19:26.547 KFBNewsroom[3697:c07] Request: <NSURLRequest http://kyfbnewsroom.com/2012/10/22/rural-votes-matter-2/?utm_source=rss&utm_medium=rss&utm_campaign=rural-votes-matter-2>
RagingGoat is offline   0 Reply With Quote
Old Oct 29, 2012, 02:29 PM   #61
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by RagingGoat View Post
I added some NSLog statements to that delegate method to verify that it is getting the URL when a row is selected.
Good. Any other predictions you want to make and test?

I find it is always a good idea to check if variables are nil when they shouldn't be. That frequently causes the app not to do what you expect it to do, because you are calling methods on a nil object, which is simply ignored.
__________________
dejo is offline   0 Reply With Quote
Old Oct 29, 2012, 03:24 PM   #62
RagingGoat
Thread Starter
macrumors regular
 
Join Date: Jun 2010
I'm not really sure what other ones to check.
RagingGoat is offline   0 Reply With Quote
Old Oct 29, 2012, 03:36 PM   #63
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by RagingGoat View Post
I'm not really sure what other ones to check.
Your delegate method contains references to 13 properties or variables, that I can see. Have you checked them all?
__________________

Last edited by dejo; Oct 29, 2012 at 03:40 PM. Reason: Updated count.
dejo is offline   0 Reply With Quote
Old Oct 30, 2012, 08:14 AM   #64
RagingGoat
Thread Starter
macrumors regular
 
Join Date: Jun 2010
Unless I've missed something, yes, I've checked them.
RagingGoat is offline   0 Reply With Quote
Old Oct 30, 2012, 08:25 AM   #65
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by RagingGoat View Post
Unless I've missed something, yes, I've checked them.
Recheck the first line of the delegate method you provided in this post.

P.S. How many properties are referenced in that line?
__________________
dejo is offline   0 Reply With Quote
Old Oct 30, 2012, 08:36 AM   #66
RagingGoat
Thread Starter
macrumors regular
 
Join Date: Jun 2010
The only property in that line is webViewController. Other properties in that method are webView, title, items, title, and link.
RagingGoat is offline   0 Reply With Quote
Old Oct 30, 2012, 08:40 AM   #67
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
What is this?:
Code:
[self navigationController]
__________________
dejo is offline   0 Reply With Quote
Old Oct 30, 2012, 09:32 AM   #68
RagingGoat
Thread Starter
macrumors regular
 
Join Date: Jun 2010
Quote:
Originally Posted by dejo View Post
What is this?:
What do you mean?
RagingGoat is offline   0 Reply With Quote
Old Oct 30, 2012, 10:06 AM   #69
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by RagingGoat View Post
What do you mean?
What kind of element is navigationController?

Yes, in this case it's a method call to an accessor, but in the overall scheme of things what is navigationController in relation to your ListViewController, which is a subclass of UITableViewController, which itself is a subclass of UIViewController?

It's a property, as can be seen in the UIViewController Class Reference.

So, what is the value of navigationController when you try to push the web view controller onto the navigation stack?
__________________
dejo is offline   0 Reply With Quote
Old Oct 30, 2012, 02:48 PM   #70
RagingGoat
Thread Starter
macrumors regular
 
Join Date: Jun 2010
I replaced
Code:
[[self navigationController]pushViewController:webViewController animated:YES];
with
Code:
[self presentViewController:webViewController animated:YES completion:nil];
and it works now.

I still have some things to figure out but I think I can work through them.

Thanks guys!
RagingGoat is offline   0 Reply With Quote
Old Oct 30, 2012, 03:22 PM   #71
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Yeah, in order to ease navigation, you'll probably want to integrate a UINavigationController at some point. I'd suggest right from the beginning and then push new view controllers onto the stack as you drill down. You might have a look through the entire View Controller Programming Guide for iOS to understand what your options are.

P.S.

Quote:
Originally Posted by RagingGoat View Post
I replaced
Code:
[[self navigationController]pushViewController:webViewController animated:YES];
with
Code:
[self presentViewController:webViewController animated:YES completion:nil];
Care to tell us what made you come to that decision?
__________________

Last edited by dejo; Oct 30, 2012 at 06:54 PM. Reason: Added P.S.
dejo is offline   0 Reply With Quote
Old Nov 5, 2012, 10:44 AM   #72
RagingGoat
Thread Starter
macrumors regular
 
Join Date: Jun 2010
I've added this code to KFBAppDelegate and now I'm not sure how to push the navigationcontroller to the other views.

Code:
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[KFBViewController alloc] initWithNibName:@"KFBViewController" bundle:nil]];
    self.window.rootViewController = nav;
I would think something like this

Code:
[[self navigationController]pushViewController:webViewController animated:YES];
I'm wanting the navigation bar with a back button on all views (except the root view obviously)

Here is the current project without the navigation controller code put in the appdelegate file for reference.
https://www.dropbox.com/s/sv0y3oh1af...wsroom%204.zip
RagingGoat is offline   0 Reply With Quote
Old Nov 5, 2012, 11:15 AM   #73
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by RagingGoat View Post
I would think something like this...
You think? What have you tried? If you continue to guess at solutions, I'm not sure I can be of help anymore.

P.S. You seem to have a tab-bar app. You should be setting your rootViewController to a UITabBarController.
__________________
dejo is offline   0 Reply With Quote
Old Nov 5, 2012, 11:19 AM   #74
RagingGoat
Thread Starter
macrumors regular
 
Join Date: Jun 2010
I'm wanting to have a tab bar with a home item and a couple of items that go to other views but I also want a navigation bar with a back button.
RagingGoat is offline   0 Reply With Quote
Old Nov 5, 2012, 01:08 PM   #75
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by RagingGoat View Post
I'm wanting to have a tab bar with a home item and a couple of items that go to other views but I also want a navigation bar with a back button.
Alright. What do you know about combining a tab-bar-based app with a navigation-based one? If not much, how are you planning on learning about it?
__________________
dejo is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Tableview Reload headache VolceOntra iPhone/iPad Programming 6 May 11, 2014 01:19 PM
Resolved: NumberFormatter in TableView Qaanol Mac Programming 3 Dec 25, 2013 07:56 PM
parsing and displaying in tableview jennylcf iPhone/iPad Programming 2 Jan 28, 2013 06:31 AM
Populating TableView Mvkoe iPhone/iPad Programming 5 Dec 1, 2012 04:34 PM
Resolved: Help with TableView data troop231 iPhone/iPad Programming 2 Jun 26, 2012 12:49 PM

Forum Jump

All times are GMT -5. The time now is 09:30 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC