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-11-2010, 04:19 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 16
eddyxd is on a distinguished road
Default How can I achieve this effect?? (about add a new view)

-- here is what i want to do --

I have view1(with some user info) and view2(with some UIDatePicker or other UI)

And after user touch the button "change" in view1 , the app will pop up view2(with down up animation) and the background of view2 is translucent, so we still can see part of view1 behind of view2.

After user finish changing in view2 and push "ok" button , view2 would pop out with up down animation back to view1.





-- here is what i have tried --

1. using addSubView and removeFromSuperView with customized animation.
It works perfectly when changing to view2, but it does't work when I pop back to view1(there is no animation...)

2. using presentModalViewController (I think it would be a better and smarter way!)
But everytime after view 2 sliding up to it's position , the view1 just disapper@@!! (view1 would perform perfectly as i want during view2 is sliding that is we still can see view1 behind part of view2@@)


So how could I figure out this problem??

ps: I tried to cancel the check-box:"Opaque"and "clear context before drawing" of view2 in IB, but still have not any effect in thisQQ.

Does anyone has any idea? or could you give some advice to implement this function what i want in more easier way.

Thanks.~

Last edited by eddyxd; 09-11-2010 at 04:21 AM.
eddyxd is offline   Reply With Quote
Old 09-11-2010, 07:56 AM   #2 (permalink)
Registered Member
 
Join Date: Aug 2010
Age: 16
Posts: 9
nesh96 is on a distinguished road
Default

Try self.view.alpha = 0.80 in view2 to make it translucent.
nesh96 is offline   Reply With Quote
Old 09-11-2010, 08:31 AM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 16
eddyxd is on a distinguished road
Default

Quote:
Originally Posted by nesh96 View Post
Try self.view.alpha = 0.80 in view2 to make it translucent.
YES@@ I have configured this to make view2 be translucent.

But after the Modal animation effect, the I-phone would likely pop out view1 even view2 is translucentQQ
eddyxd is offline   Reply With Quote
Old 09-11-2010, 09:20 AM   #4 (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 eddyxd View Post
-- here is what i want to do --

I have view1(with some user info) and view2(with some UIDatePicker or other UI)

And after user touch the button "change" in view1 , the app will pop up view2(with down up animation) and the background of view2 is translucent, so we still can see part of view1 behind of view2.

After user finish changing in view2 and push "ok" button , view2 would pop out with up down animation back to view1.





-- here is what i have tried --

1. using addSubView and removeFromSuperView with customized animation.
It works perfectly when changing to view2, but it does't work when I pop back to view1(there is no animation...)

2. using presentModalViewController (I think it would be a better and smarter way!)
But everytime after view 2 sliding up to it's position , the view1 just disapper@@!! (view1 would perform perfectly as i want during view2 is sliding that is we still can see view1 behind part of view2@@)


So how could I figure out this problem??

ps: I tried to cancel the check-box:"Opaque"and "clear context before drawing" of view2 in IB, but still have not any effect in thisQQ.

Does anyone has any idea? or could you give some advice to implement this function what i want in more easier way.

Thanks.~
Pushing a modal view controller won't work because the system will take away the underlying view once the modal view controller is animated into place.

Here's what you need to do:

In the nib file for the view controller where you want present the date picker dialog, add a new view, just inside the view controller's main view. Make your new view the same size as it's parent view (full screen size). In IB, set the background color of your view to black (or white, depending on the look you want) with an opacity of .3 to .5. This will cause the view to partly obscure the view below, but allow it to show through slightly. Play with the opacity value to get the effect you want.

Add subviews centered inside that the "date picker view" that contain the UI elements you need, including a date picker, buttons, etc.

After you have the contents the way you want them, click the "hidden" checkbox on the outermost "date picker view". This will cause that view to not be drawn.

Create outlets and actions in your view controller to manage this new "date picker view". I suggest you group all the outlets, instance variables and methods in your code, and mark them with clear header/footer comments so you can remember what components go with your new view.

Add an IBAction method "showDatePickerView:". This method will be responsible for animating in your date picker view. Also create another method, "hideDatePickerView:" that will be responsible for reversing the process.

in showDatePickerView, do the following:

Code:
- (IBAction) showDatePickerView: (id) sender;
{
  CGPoint viewCenter;
  viewCenter = datePickerView.center;
  //The following lines move the view off-screen to the top
  //(while it's still hidden
  viewCenter.y += datePickerView.superview.frame.size.height; 
  datePickerView.center = viewCenter;

  //Now that the view is off-screen, make it visible
  datePickerView.hidden = FALSE;

  [UIView beginAnimations: @"slide_down" context: nil];
  {
    viewCenter = datePickerView.center;
    //The following lines move the view on-screen from the top.
    viewCenter.y -= datePickerView.superview.frame.size.height; 
    datePickerView.center = viewCenter;
  }
  [UIView commitAnimations];
}
Then, in your hideDatePickerView method, do this:

Code:
- (IBAction) hideDatePickerView: (id) sender;
{
  CGPoint viewCenter;
  [UIView beginAnimations: @"slide_up" context: nil];
  {
    viewCenter = datePickerView.center;
    //The following lines move the view on-screen from the top.
    viewCenter.y += datePickerView.superview.frame.size.height; 
    datePickerView.center = viewCenter;
    [UIView setAnimationDelegate: self];
    [UIView setAnimationDidStopSelector: @selector(setPickerViewHidden)];
  }
  [UIView commitAnimations];
}

//This method gets called once the hide picker view animation is complete.
//It marks it as hidden again and resets the view back to it's original position.

- (void) setPickerViewHidden;
{
  datePickerView.hidden = TRUE;  //Mark the view as hidden again for next time.

  CGPoint viewCenter;
  viewCenter = datePickerView.center;
  viewCenter.y -= datePickerView.superview.frame.size.height; 

  //Move the picker view back on-screen for next time.
  datePickerView.center = viewCenter;
}
__________________
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 09-11-2010, 09:35 PM   #5 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 16
eddyxd is on a distinguished road
Default

Duncan, thank you!

This really works and the we could write these animation code in the "pickerview" to get a so concise code structrue.

This is indeed usful, thanks a lot!
eddyxd is offline   Reply With Quote
Reply

Bookmarks

Tags
addsubview

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: 344
12 members and 332 guests
bignoggins, carlandrews, cgokey, givensur, hzwegjxg, ilmman, jenniead38, linkmx, mraalex, PixelInteractive, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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