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 Jun 2, 2011, 04:00 PM   #1
timbojill
macrumors member
 
Join Date: May 2011
How do you turn a Tab Bar Application into a View-Based Application...

How do you turn a Tab Bar Application into a View-Based Application. I have a Tab Bar Application already submitted into the app. View my blog and look at the learning Center. Instead of Tabs I want one view as my main view and that from the main view have buttons that switch to and from other xib files.
timbojill is offline   0 Reply With Quote
Old Jun 2, 2011, 10:12 PM   #2
nickculbertson
macrumors regular
 
Join Date: Nov 2010
Location: Nashville, TN
Just delete or ignore your tab bar button functions and create UIButtons to navigate your views.
Nick
__________________
My App Blog --->
nickculbertson is offline   0 Reply With Quote
Old Jun 3, 2011, 07:39 AM   #3
timbojill
Thread Starter
macrumors member
 
Join Date: May 2011
I ignored the Tab Bar and added buttons to the main view. But what is the code to have the xib files connected.
timbojill is offline   0 Reply With Quote
Old Jun 3, 2011, 08:04 AM   #4
nickculbertson
macrumors regular
 
Join Date: Nov 2010
Location: Nashville, TN
Code:
-(IBAction)changeSecondView{
SecondView *views = [[SecondView alloc] initWithNibName:Nil bundle:nil];
	[self presentModalViewController:views animated:NO];
}
You will also want to create a SecondView .h and .m file by right clicking your Class folder and selecting Add > New File. Add a UIViewController subclass (uncheck the add xib if you already have one). click Next. Set the file name to SecondView.m and make sure the Also create "SecondView.h" box is checked. Then at the top of your FirstViewController.m add
Code:
#import "SecondView.h"
Nick
__________________
My App Blog --->
nickculbertson is offline   0 Reply With Quote
Old Jun 3, 2011, 08:39 AM   #5
timbojill
Thread Starter
macrumors member
 
Join Date: May 2011
Quote:
Originally Posted by nickculbertson View Post
Code:
-(IBAction)changeSecondView{
SecondView *views = [[SecondView alloc] initWithNibName:Nil bundle:nil];
	[self presentModalViewController:views animated:NO];
}
You will also want to create a SecondView .h and .m file by right clicking your Class folder and selecting Add > New File. Add a UIViewController subclass (uncheck the add xib if you already have one). click Next. Set the file name to SecondView.m and make sure the Also create "SecondView.h" box is checked. Then at the top of your FirstViewController.m add
Code:
#import "SecondView.h"
Nick
I tried to use a .h and .m file I already had. The name is 2nd.h and 2nd.m.

So should it be:
Code:
2nd *views = [[2nd alloc] initWithNibName:Nil bundle:nil];
	[self presentModalViewController:views animated:NO];
?

Last edited by dejo; Jun 3, 2011 at 10:33 AM. Reason: Fixed code tags.
timbojill is offline   0 Reply With Quote
Old Jun 3, 2011, 09:06 AM   #6
nickculbertson
macrumors regular
 
Join Date: Nov 2010
Location: Nashville, TN
You will be loading the xib file this way. So if your xib name is "2nd" then your code is correct. the code written in your 2nd.h and .m can be linked to your 2nd.xib (or any xib for that matter) by opening interface builder -> select your files owner -> select the last tab (i) on the identity inspector window -> change class to 2nd.

Nick
__________________
My App Blog --->
nickculbertson is offline   0 Reply With Quote
Old Jun 3, 2011, 09:16 AM   #7
timbojill
Thread Starter
macrumors member
 
Join Date: May 2011
http://www.mediafire.com/?iby0z3obz9fj1ah. Can you take a look at my program and she what I am doing wrong.
timbojill is offline   0 Reply With Quote
Old Jun 3, 2011, 09:52 AM   #8
nickculbertson
macrumors regular
 
Join Date: Nov 2010
Location: Nashville, TN
The application looks pretty messy. I believe the reason it is crashing is because you are trying to change the view from a UIView, not a UIViewController. I'd recommend starting fresh with a new view based app. It shouldn't take long since all you have now are a few buttons linked to functions you are not using. In the view based app add the .h and .m files like I said but check the box to include the xib.
Good Luck,
Nick
__________________
My App Blog --->
nickculbertson is offline   0 Reply With Quote
Old Jun 3, 2011, 10:32 AM   #9
timbojill
Thread Starter
macrumors member
 
Join Date: May 2011
Quote:
Originally Posted by nickculbertson View Post
The application looks pretty messy. I believe the reason it is crashing is because you are trying to change the view from a UIView, not a UIViewController. I'd recommend starting fresh with a new view based app. It shouldn't take long since all you have now are a few buttons linked to functions you are not using. In the view based app add the .h and .m files like I said but check the box to include the xib.
Good Luck,
Nick
I already started from the beginning. I took an example of a view app and try to modify it. If you ran the program the first button works. I just need to find a way to add the other buttons to link to the other .h files and xib files I have.

EDIT:

In the example I used he added all the xib's to the main xib. I want to uses other xibs I imported.

EDIT 2:

http://www.mediafire.com/?swbm2ksyefdzzm3 nick I hope you still around. I started from the beginning with a new view-based project. In the LC4Viewcontroller.m I get an error in the IBAction that calls the first views from the main view.

Code:
- (IBAction)view2 {
    [self addSubview:Letter];
}
The error is expected expression before letter. Can anyone help me out.

EDIT 3:

Can someone add a third view called view3 and connect it for me. When I did it it said view3 undecleared. I don't know why I am having so much trouble.

http://www.esnips.com/doc/66bb2e0c-1...69b13db895/new

Last edited by dejo; Jun 3, 2011 at 12:11 PM. Reason: Consecutive posts. Please use edit feature.
timbojill 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
Resolved: Use View With Tab Bar & With Navigation Bar PBG4 Dude iPhone/iPad Programming 2 Mar 26, 2014 08:04 AM
View based vs Window based application Vishwas Gagrani iPhone/iPad Programming 1 Oct 14, 2012 05:25 PM
Issues with blutooth and new maps application (turn-by-turn)?? eroxx iOS 6 2 Sep 19, 2012 05:51 PM
Push a view on top of NOT within tab bar controller newtoiphonesdk iPhone/iPad Programming 2 Sep 9, 2012 02:45 PM
Turn By Turn Navigation vs Street View: Which is More Important in a Map Application? newagemac iOS 6 73 Jul 15, 2012 03:38 PM

Forum Jump

All times are GMT -5. The time now is 01:33 PM.

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

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