how to call a presentModalView from a subView? - iphone

i'm working in ipad application,i have a viewController A which have many subviews viewcontroller b,c,d,e,f... when i want to select a cell from one of viewcontroller to have a prsent modal view "full screen" it's not working ,how can i fix that

as you have added all the viewcontroller as a subview you don't need to present it
you just try
[self.view bringsubviewtofront:a.view];
hope this help ,
EDIT
use following local notification calling methods to solve your problem,
//place in class from which you want to perform action
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(openLarge:)name:#"openLarge" object:nil];
//place in class where you want to perform action
[[NSNotificationCenter defaultCenter] postNotificationName:#"openLarge"
object:nil userInfo:nameDict];
regards,

Related

UINavigationBar height is reducing after re-enteringforeground

My controller main view call
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:YES];
in it's viewDidAppearmethod because the screen must be manually rotated for the user.
Everything works perfectly except when I put the app in background and I re-enter foreground on this screen: Then the navigationBar's height become 32px.
If I comment the setStatusBarOrientation call, then no problem.
I've logged the navigationBar height in didEnterForeground method (after the super call), but it tells 44px. So I guess it would be resized after.
So I would like to know :
If there was a way to prevent the navigationBar to be resized
If no, what other callback method would come after the didEnterForeground one (viewWill/DidAppear does'nt)
Thanks !
After 4 months, I finally found a partial solution !
If no, what other callback method would come after the didEnterForeground one (viewWill/DidAppear does'nt)
I found a good callback when a viewController (not app delegate) is re-entering foreground. With NSnotificationCenter
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(willEnterForeground:) name:UIApplicationWillEnterForegroundNotification object:nil];
don't forget to remove
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil];

How to get a pointer to a viewController inside the appDelegate when using storyboards

I'm trying to save the data from a viewController. I'm doing this by using the delegate methods in the appDelegate: - (void)applicationDidEnterBackground:(UIApplication *)application
The problem is when using storyboards, the viewControllers automatically get set up for you and I'm not sure how to get a pointer to them so that I can access their data for saving.
How can I get a pointer to them in appDelegate while using storyboards?
You can register to receive going to and from background notification inside your UIViewController and manage the saving there.
//Going into background
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(saveData) name:#"UIApplicationDidEnterBackgroundNotification" object:nil];
//Waking up
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(doSomethingOnWakeup) name:#"UIApplicationWillEnterForegroundNotification" object:nil];

Performing an action on one view, and the action doing something on another view? Is this possible?

I have 2 views:
OneViewController
TwoViewController
TwoViewController has an IBAction which plays a sound. Once the user has pressed the button on TWoViewController I want a UILabel which will appear on OneViewController saying that the sound has been played.
Thanks for the help
All you have to do is reference one viewController in the other one, that way you can call it's methods. Or you can simply create a delegate.
One possible solution is to use notifications.
In the action that plays a sound, post a notification to the default notification center that indicates the sound has played.
[[NSNotificationCenter defaultCenter] postNotificationName:"playSoundNotification"
object:self
userInfo:nil];
When OneViewController is created, have it register for the notification.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(showPlayedLabel:)
name:"playSoundNotification"
object:nil];
When it receives the notification -- in showPlayedLabel: -- display the UILabel. Note that showPlayedLabel must follow the appropriate signature format.
- (void) showPlayedLabel:(NSNotification*) aNotification;

iphone: Preserve view on top of mpMoviePlayerController

I have a mpMoviePlayerController, and I have subview on top of it. When the user taps the fullscreen button of the mpMoviePlayerController, the subview disappears, and only appears when I go back to the original size. Is there a way to keep the subview? Is there a way to get a reference of the "scaled" moviePlayer?
Quick Draft:
trap MPMoviePlayerWillEnterFullscreenNotification like this:
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:#selector(MPMoviePlayerDidEnterFullscreen:)
name:MPMoviePlayerDidEnterFullscreenNotification
object:nil];
within MPMoviePlayerDidEnterFullscreen, add that subview onto the current keyWindow like this:
[[[UIApplication sharedApplication]
keyWindow]
addSubview:mySpecialSubview]

Returning from dismiss modal view controller - any way to detect?

Wonder if anyone can help me. I have a setup whereby a main menu presents the main game as a modal view controller. At this point it also stops playing the main menu music.
The problem is that when the game view controller dismisses itself (e.g when user quits game) and returns to the main menu I cannot get the main menu music to start playing again.
Is there some way I can get the music in the main menu to start playing again ? E.g a delegate method that is called when the main game dismisses ?
Thanks,
Martin
You can do it with the NotificationManager
// set up notification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(playMusic:)
name:#"musicNotification"
object:nil];
// send notification
[[NSNotificationCenter defaultCenter] postNotificationName:#"musicNotification"
object:self];
// clean up notification
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
- (void) playMusic:(NSNotification *) notification
{
// play the music here
if ([[notification name] isEqualToString:#"musicNotification"])
NSLog (#"Received musicNotification!");
}