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 01-22-2012, 10:34 AM   #1 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 10
dynamite88 is on a distinguished road
Default Sliding view controllers and be able to reference the IBActions

Hi All,

I want to be able to switch from screen to screen created from the same view controller with the sliding left/right transition. So far I've tried the solution posted on this forum does not work for me (reference):

Code:
Just for those who are stranded like I was ...here's some code that worked for me. with this the new view slid in 
//1. Add the QuatzCore Framework from library to the Frameworks folder
//2. At the top include the header file

#import <QuartzCore/QuartzCore.h>

//3. Implement the code 

yourViewController = [[YourViewController alloc] 
initWithNibName:@"YourViewController" 
bundle:nil];
// get the view that's currently showing
UIView *currentView = self.view;
// get the the underlying UIWindow, or the view containing the current view
UIView *theWindow = [currentView superview];

UIView *newView = yourViewController.view; 

// remove the current view and replace with myView1
[currentView removeFromSuperview];
[theWindow addSubview:newView];

// set up an animation for the transition between the views
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseO ut]];

[[theWindow layer] addAnimation:animation forKey:@"SwitchToView1"];
I also checked out another sample from Apple: Apple sample code

The two samples above do not slide to a view with interactions. I haven't been able to find a good example where we could possibly continually keep sliding left to a new screen without crashing (I get stuck on the first new screen since references to the IBActions are lost)? Any ideas on how to accomplish this?

Thanks in advance!

-J
dynamite88 is offline   Reply With Quote
Old 01-28-2012, 04:28 PM   #2 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 3
DFly is on a distinguished road
Default

Gent,

I'm using a Tabbarcontroller and i want to change the first tab view to another view (not tab view!) slide to right/left like you do. initWithNibName and others like viewDidLoad are not triggered in my sliding view. Also how to i go back?

did you ever found solution for this?
DFly is offline   Reply With Quote
Old 01-28-2012, 06:18 PM   #3 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by dynamite88 View Post
Hi All,

I want to be able to switch from screen to screen created from the same view controller with the sliding left/right transition. So far I've tried the solution posted on this forum does not work for me (reference):

Code:
Just for those who are stranded like I was ...here's some code that worked for me. with this the new view slid in 
//1. Add the QuatzCore Framework from library to the Frameworks folder
//2. At the top include the header file

#import <QuartzCore/QuartzCore.h>

//3. Implement the code 

yourViewController = [[YourViewController alloc] 
initWithNibName:@"YourViewController" 
bundle:nil];
// get the view that's currently showing
UIView *currentView = self.view;
// get the the underlying UIWindow, or the view containing the current view
UIView *theWindow = [currentView superview];

UIView *newView = yourViewController.view; 

// remove the current view and replace with myView1
[currentView removeFromSuperview];
[theWindow addSubview:newView];

// set up an animation for the transition between the views
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseO ut]];

[[theWindow layer] addAnimation:animation forKey:@"SwitchToView1"];
I also checked out another sample from Apple: Apple sample code

The two samples above do not slide to a view with interactions. I haven't been able to find a good example where we could possibly continually keep sliding left to a new screen without crashing (I get stuck on the first new screen since references to the IBActions are lost)? Any ideas on how to accomplish this?

Thanks in advance!

-J

Do you mean that you want to transition from one view controller to a different instance of the same view controller that displays different content?

Or are you trying to have a single instance of a view controller that manages multiple pages as views, and slides from one to the next?

If the second, do you have a small, fixed number of views that you want to display, or do you want to be able to display an arbitrary number of views?


The first approach might be a lot simpler than the second. Create a new instance of your view controller, set a custom transition, and push it onto a navigation controller. (or use a Segue if you're using Storyboards.)
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Reply

Bookmarks

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: 389
9 members and 380 guests
7twenty7, Atatator, FrankWeller, glenn_sayers, iphonedevshani, MAMN84, QuantumDoja, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,674
Threads: 94,122
Posts: 402,907
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Atatator
Powered by vBadvanced CMPS v3.1.0

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