Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Tab Bar and Navigation Bar xcode 4

Hi,

I am noob in xcode 4 and I was wondering if anyone could help me. I used this tutorial http://cocoadevblog.com/iphone-tutorial-creating-a-rss-feed-reader#comment-3839 to learn how to create a simple rss reader app (which worked like a charm) then I off course decided to do the follwoing


1-create a new app based on the tab navigation

2-add a new navigation based window

3-link the first tab to the new nav window view


however now the self doesnt seem to be doing anything at all.


self.title is not working

and self.tableview also doesnt do anything.


I am assuming that the self in that table is getting lost and not pointing to the proper view.


any help would be greatly appreciated.


I attached both projects on the the following link from cloudme



http://my.cloudme.com/f1andy83/webshare/both%20projects.zip



Andre

XCode 4-OTHER, iOS 4.3.2

Posted on Jun 11, 2011 9:43 AM

Reply
Question marked as Best reply

Posted on Jun 12, 2011 7:33 AM

OK, there is couple of things that you did wrong.

First you trying to build app with tab navigation but using some code from rss reader app that is build on top of navigation controller:

NewsController.m>viewDidLoad method:


UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];

indicator.hidesWhenStopped = YES;

[indicator stopAnimating];

self.activityIndicator = indicator;

[indicator release];

UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithCustomView:indicator];

self.navigationItem.rightBarButtonItem = rightButton;


You are trying to add Activity indicator as navigation item but your app doesn't use navigation controller, it uses tab bar controller.


Another thing is (self.title = @"MMO News"; )

In rss app this line of code is setting title of navigation bar. But like I said you don't have navigation controller in your app, so this line of code is actually setting title of tab bar item. If you start your app in simulator you will see that you first tab bar item is called "MMO News" not "News" as you called it in Interface builder.


Second you are not downloading rss feed at all.

You forgot to add this line of code([self loadData];) in NewsController.m>viewDidAppear, and you need to return 1 not 0 in NewsController.m>numberOfSectionsInTableView.



I am afraid that this is too complicated example to start learning with. Analyze code, and if you can't figure out what each line of code do, ask someone or start with some simpler examples.



Ivan Glisic

2 replies
Question marked as Best reply

Jun 12, 2011 7:33 AM in response to f1andy83

OK, there is couple of things that you did wrong.

First you trying to build app with tab navigation but using some code from rss reader app that is build on top of navigation controller:

NewsController.m>viewDidLoad method:


UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];

indicator.hidesWhenStopped = YES;

[indicator stopAnimating];

self.activityIndicator = indicator;

[indicator release];

UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithCustomView:indicator];

self.navigationItem.rightBarButtonItem = rightButton;


You are trying to add Activity indicator as navigation item but your app doesn't use navigation controller, it uses tab bar controller.


Another thing is (self.title = @"MMO News"; )

In rss app this line of code is setting title of navigation bar. But like I said you don't have navigation controller in your app, so this line of code is actually setting title of tab bar item. If you start your app in simulator you will see that you first tab bar item is called "MMO News" not "News" as you called it in Interface builder.


Second you are not downloading rss feed at all.

You forgot to add this line of code([self loadData];) in NewsController.m>viewDidAppear, and you need to return 1 not 0 in NewsController.m>numberOfSectionsInTableView.



I am afraid that this is too complicated example to start learning with. Analyze code, and if you can't figure out what each line of code do, ask someone or start with some simpler examples.



Ivan Glisic

Jun 12, 2011 7:53 AM in response to glisic

omg dont i feel stupid, you nailed it, my problem was the number of sections indeed. Somehow I didnt see that it was returning 0 instead of 1, as soon as i changed it to 1 it worked. thanks so much. you have no idea how frustrated i was. if you lived near me I would take you out for dinner to say thanks lol. phew. you the man.

Tab Bar and Navigation Bar xcode 4

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