Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-24-2010, 10:15 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 28
nick.provost is on a distinguished road
Default Button on second view does not work.

In my app i have a regular button that brings me to another nib file using this action

-(IBAction)kongchangeid)sender
{
viewController *Kong = [[viewController alloc] initWithNibName:@"Kong" bundle:nil];
[window addSubview: [Kong view]];
[Kong release];
}

it works perfectly fine.
but I have another button on the nib file named "Kong" that i want to use to go back.
I decided not to use a navigation controller because it doesnt let me change the colour of the navigation bar.
When ever i click on the button on the view of Kong, the app restarts.
I tried connecting the button to an IBAction method in the app delegate or the view controller. Even if i dont put any code in the method it restarts.

This is my first post and i just started coding this week so i'm a noob.
nick.provost is offline   Reply With Quote
Old 09-25-2010, 06:17 AM   #2 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 28
nick.provost is on a distinguished road
Default

I dont know if this helps but i have a Tab bar based application. Please help me!
nick.provost is offline   Reply With Quote
Old 09-25-2010, 06:30 AM   #3 (permalink)
I will be a billionaire.
 
IphoneSdk's Avatar
 
Join Date: Sep 2009
Location: Scarborough, United Kingdom
Age: 17
Posts: 1,344
IphoneSdk is on a distinguished road
Default

Watch a simple tutorial on how to switch views. It isn't rocket science - Let me google that for you
__________________
iOS Apps | Website | Twitter | Facebook
IphoneSdk is offline   Reply With Quote
Old 09-25-2010, 06:40 AM   #4 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 28
nick.provost is on a distinguished road
Default

i have watched many. But perhaps not the right ones. Most of them were for navigation based applications but i found one on youtube for tab bar based but it was with a navigation controller which i dont want to use because of the colour of the navigation bar.
At this point its not the navigation i'm worried about. Its just that the button on my new view will make my app restart even with no code in it. Any ideas on where i should put the -(IBAction) method? maybe thats the problem.
nick.provost is offline   Reply With Quote
Old 09-25-2010, 06:47 AM   #5 (permalink)
I will be a billionaire.
 
IphoneSdk's Avatar
 
Join Date: Sep 2009
Location: Scarborough, United Kingdom
Age: 17
Posts: 1,344
IphoneSdk is on a distinguished road
Default

Code to go to next page:

Code:
- (IBAction) gotonext {
	SecondDetailViewController *viewController = [[SecondDetailViewController alloc] initWithNibName:@"SecondDetailView" bundle:nil];
	[self presentModalViewController:viewController animated:YES];
	[viewController release];
}
Code to go back:

Code:
- (IBAction) back {

[self dismissModalViewController:YES];

}
__________________
iOS Apps | Website | Twitter | Facebook
IphoneSdk is offline   Reply With Quote
Old 09-25-2010, 09:50 AM   #6 (permalink)
Fly-by-night Innovator
 
Join Date: Jun 2010
Posts: 364
musicwind95 is on a distinguished road
Default

"I decided not to use a navigation controller because it doesnt let me change the colour of the navigation bar."

Err...UINavigationBar does in fact have a tintColor property, which allows you to set its color. You can do this in IB by selecting the navigation bar and using the 1st inspector.
__________________
If I have helped you, please consider donating. I use PayPal. It would mean a lot to me!


For more iOS Development, check out my blog—Cups of Cocoa. All visitors welcome, but especially beginners!

Hope I have helped!

Please check out IceFall, a new action game available in the App Store!
musicwind95 is offline   Reply With Quote
Old 09-25-2010, 03:40 PM   #7 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 28
nick.provost is on a distinguished road
Default

IphoneSdk :
i entered this in my viewController.m
-(IBAction)gotonext
{
viewController *ViewController = [[viewController alloc] initWithNibName:@"Kong" bundle:nil];
[self presentModalViewController:ViewController animated:YES];
[ViewController release];

}
and when i clicked on my button, my app restarted.


musicwind95:
i know i can change it of colour.. and regularly it lets me but when theres a navigation controller involve i no longer have that option in inspector
nick.provost is offline   Reply With Quote
Old 09-25-2010, 03:45 PM   #8 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 28
nick.provost is on a distinguished road
Default

never mind! i put the code and it doesn't restart my app.... but the view stays the same and it doesn't do anything.
I dont know what I am doing wrong :S
nick.provost is offline   Reply With Quote
Old 09-25-2010, 03:54 PM   #9 (permalink)
I will be a billionaire.
 
IphoneSdk's Avatar
 
Join Date: Sep 2009
Location: Scarborough, United Kingdom
Age: 17
Posts: 1,344
IphoneSdk is on a distinguished road
Default

Have you hooked things up in Interface Builder?
__________________
iOS Apps | Website | Twitter | Facebook
IphoneSdk is offline   Reply With Quote
Old 09-25-2010, 04:20 PM   #10 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 28
nick.provost is on a distinguished road
Default

yes i linked my button to the method
nick.provost is offline   Reply With Quote
Old 09-25-2010, 05:23 PM   #11 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 28
nick.provost is on a distinguished road
Default

maybe this will clear things up
the problem is when i connect a button that is on my Subview to a method.
When ever i connect that button to a method in viewController or the AppDelegate and press it, the app restarts
it might do this because its on the subview?
nick.provost is offline   Reply With Quote
Old 09-25-2010, 05:45 PM   #12 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 57
Conor.Higgins is on a distinguished road
Default

Nick,

are you still having problems with this now or did you fix it? Your last reply was a little inconclusive.

Conor
Conor.Higgins is offline   Reply With Quote
Old 09-25-2010, 05:50 PM   #13 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 57
Conor.Higgins is on a distinguished road
Default

Quote:
Originally Posted by nick.provost View Post
maybe this will clear things up
the problem is when i connect a button that is on my Subview to a method.
When ever i connect that button to a method in viewController or the AppDelegate and press it, the app restarts
it might do this because its on the subview?
Can you post the code you are using in both view controllers?
Presenting a modal view controller is really only calling a new view rather than a sub view. Therefore if your app is showing a single modal view controller, calling [self dismissModalViewController:YES] will remove it from view.
Conor.Higgins is offline   Reply With Quote
Old 09-25-2010, 05:52 PM   #14 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 22
dethmaShine is on a distinguished road
Default

There's no need to call yourself a noob. There's always another bug. Don't worry.

Hey if you have a subview, the just do this:

-(void)switchBack{
[self.view removeFromSuperView];
}

You put this in that particular viewController that you just instantiated.

Map this to that particular button and that's it. Report with any errors.
dethmaShine is offline   Reply With Quote
Old 09-25-2010, 06:05 PM   #15 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 28
nick.provost is on a distinguished road
Default

dethmaShine, wouldn't it be an IBAction since i need to connect it to a button?
nick.provost is offline   Reply With Quote
Old 09-25-2010, 06:09 PM   #16 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 22
dethmaShine is on a distinguished road
Default

Quote:
Originally Posted by nick.provost View Post
dethmaShine, wouldn't it be an IBAction since i need to connect it to a button?
I apologise: It has to be an IBAction:

Code:
-(IBAction)switchBack{
[self.view removeFromSuperView];
}
dethmaShine is offline   Reply With Quote
Old 09-25-2010, 06:09 PM   #17 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 28
nick.provost is on a distinguished road
Default

Conor,
theres no code in my view Controllers... only what was already there.
all my methods are in the app Delegate since I am referencing to window that is declared in the apps delegate .h file
i am referencing window in this method

-(IBAction)kongchangeid)sender
{
viewController *Kong = [[viewController alloc] initWithNibName:@"Kong" bundle:nil];
[window addSubview: [Kong view]];
[Kong release];
}
nick.provost is offline   Reply With Quote
Old 09-25-2010, 06:12 PM   #18 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 22
dethmaShine is on a distinguished road
Default

Quote:
Originally Posted by nick.provost View Post
dethmaShine, wouldn't it be an IBAction since i need to connect it to a button?
Also, I wouldn't go against anyone but modalviewcontrollers are used to pass in data and other interactions.

If you just need to move on to a different view altogether and work in that workspace, you must subview it. ModalViewControllers are easy to use but they do not give the right indication of what you are trying to display.

Also, I would suggest you making a viewBased application and going for a similar approach just to build up some confidence.

Switching is pretty complex. IMO, it takes most of your understand of how/when to use simple view/navigation/tab bar controllers.

All the best, report with any errors.
dethmaShine is offline   Reply With Quote
Old 09-25-2010, 06:35 PM   #19 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 28
nick.provost is on a distinguished road
Default

dethmaShine,
i put the method in my viewController and connected my button to it.
But when i click on the button it restarts the app.
Il tell you guys exactly what im doing do you can tell me what i'm doing wrong.

I have a MainWindow with a Tab Controller.
One of the tabs has a button on it that links to a method in my AppDelegate.
This method is:

-(IBAction)viewchangeid)sender
{
viewController *view1 = [[viewController alloc] initWithNibName:@"view1" bundle:nil];
[window addSubview: [view1 view]];
[view1 release];
}

This successfully brings me to that view.
View1 has a navigation bar with a normal "bar button item" on it
that bar button is connected to a method in viewController

this method is:
-(IBAction)viewback{
[self.view removeFromSuperView];
}
nick.provost is offline   Reply With Quote
Old 09-25-2010, 06:45 PM   #20 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 22
dethmaShine is on a distinguished road
Default

Quote:
Originally Posted by nick.provost View Post
dethmaShine,
i put the method in my viewController and connected my button to it.
But when i click on the button it restarts the app.
Il tell you guys exactly what im doing do you can tell me what i'm doing wrong.

I have a MainWindow with a Tab Controller.
One of the tabs has a button on it that links to a method in my AppDelegate.
This method is:

-(IBAction)viewchangeid)sender
{
viewController *view1 = [[viewController alloc] initWithNibName:@"view1" bundle:nil];
[window addSubview: [view1 view]];
[view1 release];
}

This successfully brings me to that view.
View1 has a navigation bar with a normal "bar button item" on it
that bar button is connected to a method in viewController

this method is:
-(IBAction)viewback{
[self.view removeFromSuperView];
}
It's hard to understand how you have placed your views. It would be great if you could attach the project in your next post.
dethmaShine is offline   Reply With Quote
Old 09-25-2010, 06:50 PM   #21 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 28
nick.provost is on a distinguished road
Default

how do i do that? i tried putting it all in a .zip
but its 700 kb which "exceeds the sites size limit for files this type" when i try to attach it
nick.provost is offline   Reply With Quote
Old 09-25-2010, 06:57 PM   #22 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 28
nick.provost is on a distinguished road
Default

here i made a similar app with nothing on it except the essentials.
even then i couldnt include the folder build
hopefully you guys can still see what i did
Attached Files
File Type: zip app.zip (22.6 KB, 4 views)
nick.provost is offline   Reply With Quote
Old 09-25-2010, 07:41 PM   #23 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 28
nick.provost is on a distinguished road
Default

sorry. that app had no connection to the second button...
here
Attached Files
File Type: zip App.zip (22.8 KB, 5 views)
nick.provost is offline   Reply With Quote
Old 09-26-2010, 12:31 PM   #24 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 28
nick.provost is on a distinguished road
Default

please help me guys i really dont know what to do
nick.provost is offline   Reply With Quote
Old 09-26-2010, 03:55 PM   #25 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 28
nick.provost is on a distinguished road
Default

thanks for the help guys!
i decided to go for a window bases application with a navigation controller instead
i used this video as help
YouTube - Building an iPhone App Combining Tab Bar, Navigation and Tab

im pretty sure the problem was my view controller though
nick.provost is offline   Reply With Quote
Reply

Bookmarks

Tags
button, view

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 341
8 members and 333 guests
2ndSegment, headkaze, mistergreen2011, Objective Zero, pungs, revg, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:07 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0