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 02-02-2012, 03:03 PM   #1 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Question View doesn't show 2nd time when switching views?

Hey,

In my app when I am switching views with an animation using UIView animations, it works fine the first time when I switch views because the view slides properly into place and everything works. But if I switch back to my original view and then go BACK to the new view, it does not show anything, the view is black but I know my method is getting called.

My code is below, but does anyone see anything that is wrong?

Code:
-(void)changeView2ToView3 {
    NSLog(@"Before, frame= %@", NSStringFromCGRect(view3.view.frame));
        
    [view2.view.superview addSubview:view3.view];
    [view3.view setFrame:CGRectMake(0, kHeight, kWidth, kHeight)];
    [UIView animateWithDuration:0.75 
                     animations:^{
                         [view3.view setFrame:CGRectMake(0, 0, kWidth, kHeight)];  
                     }
                     completion:^(BOOL finished){
                         [view2.view removeFromSuperview];
                     }];
    NSLog(@"Before, frame= %@", NSStringFromCGRect(view3.view.frame));
}
kHeight and kWidth are the height and width of the screen and they are never 0 or nil.

Also this is what is printed from the console:
Code:
2012-02-02 15:58:30.449 App[27578:707] Before, frame= {{0, 0}, {320, 480}}
2012-02-02 15:58:30.452 App[27578:707] Before, frame= {{0, 0}, {320, 480}}
2012-02-02 15:58:36.234 App[27578:707] Before, frame= {{0, 0}, {320, 480}}
2012-02-02 15:58:36.237 App[27578:707] Before, frame= {{0, 0}, {320, 480}}
Thanks!
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8
Objective Zero is offline   Reply With Quote
Old 02-02-2012, 03:45 PM   #2 (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 Objective Zero View Post
Hey,

In my app when I am switching views with an animation using UIView animations, it works fine the first time when I switch views because the view slides properly into place and everything works. But if I switch back to my original view and then go BACK to the new view, it does not show anything, the view is black but I know my method is getting called.

My code is below, but does anyone see anything that is wrong?

Code:
-(void)changeView2ToView3 {
    NSLog(@"Before, frame= %@", NSStringFromCGRect(view3.view.frame));
        
    [view2.view.superview addSubview:view3.view];
    [view3.view setFrame:CGRectMake(0, kHeight, kWidth, kHeight)];
    [UIView animateWithDuration:0.75 
                     animations:^{
                         [view3.view setFrame:CGRectMake(0, 0, kWidth, kHeight)];  
                     }
                     completion:^(BOOL finished){
                         [view2.view removeFromSuperview];
                     }];
    NSLog(@"Before, frame= %@", NSStringFromCGRect(view3.view.frame));
}
kHeight and kWidth are the height and width of the screen and they are never 0 or nil.

Also this is what is printed from the console:
Code:
2012-02-02 15:58:30.449 App[27578:707] Before, frame= {{0, 0}, {320, 480}}
2012-02-02 15:58:30.452 App[27578:707] Before, frame= {{0, 0}, {320, 480}}
2012-02-02 15:58:36.234 App[27578:707] Before, frame= {{0, 0}, {320, 480}}
2012-02-02 15:58:36.237 App[27578:707] Before, frame= {{0, 0}, {320, 480}}
Thanks!
Do all these views you're dealing with belong to the same view controller, or are you swapping view controllers around? If you're swapping view controllers, don't do that. It will get you in a world of trouble.

You CAN do that with the new iOS 5 child view controller support, but that's the only way you should do it.
__________________
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
Old 02-02-2012, 03:48 PM   #3 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
Do all these views you're dealing with belong to the same view controller, or are you swapping view controllers around? If you're swapping view controllers, don't do that. It will get you in a world of trouble.

You CAN do that with the new iOS 5 child view controller support, but that's the only way you should do it.
No, each view has its own view controller. Would you mind sharing a link to the new way I should do it in iOS 5 since my app will be iOS 5 only anyway?
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8
Objective Zero is offline   Reply With Quote
Old 02-03-2012, 04:50 PM   #4 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Default

Quote:
Originally Posted by Objective Zero View Post
No, each view has its own view controller. Would you mind sharing a link to the new way I should do it in iOS 5 since my app will be iOS 5 only anyway?
Bump
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8
Objective Zero is offline   Reply With Quote
Old 02-03-2012, 07:41 PM   #5 (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 Objective Zero View Post
No, each view has its own view controller. Would you mind sharing a link to the new way I should do it in iOS 5 since my app will be iOS 5 only anyway?
It's described pretty well in the UIViewController class reference. Search on the string "Implementing a Container View Controller" to find the specific section.

Also make sure you look at the method transitionFromViewController:toViewController:dura tionptions:animations:completion.
__________________
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

Tags
view no show

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: 403
16 members and 387 guests
Atatator, chiataytuday, dre, FrankWeller, imac74, ipodphone, jeroenkeij, kukat, LunarMoon, MAMN84, n00b, QuantumDoja, reficul, Retouchable, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,675
Threads: 94,124
Posts: 402,909
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Retouchable
Powered by vBadvanced CMPS v3.1.0

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