UIModalPresentationFullScreen - backgroundColor behind TransitionAnimation - iphone

I'm currently building a universal app.
After the user taps a button, I present some settings in a modal View in the following way:
viewCtrl.modalPresentationStyle = UIModalPresentationFullScreen;
viewCtrl.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:viewCtrl animated:YES];
On the iPhone and iPad both Transitionsstyles look the same. Now the problem is, on the iPad the background, behing the tilting view, is white. This white background just looks ugly.
On the iPhone it is black, as it is supposed to be.
I also tried adding a black backgroundview to my [UIApplication window]
UIView *bgView = [[UIView alloc] init];
[bgView setBackgroundColor:[UIColor blackColor]];
[window addSubview:bgView];
but it doesn't make a difference.

I think it is as simple as setting the UIWindow background color to black. For example, if you open the MainWindow.xib in IB, you should be able to set the background there - or in your AppDelegate you should be able to set the background of the UIWindow.

Related

UIView not appearing over keyboard?

I have this code:
JMenuController *menuController = [[JMenuController alloc] init];
NSArray *buttonsArray = [NSArray arrayWithObjects:#"From Libary", #"Take Photo or Video", nil];
[menuController showMenuWithTitle:#"Add Media" ButtonTitles:buttonsArray animated:YES];
self.currentMenuType = JCreateMenuTypeNewMedia;
[[[[UIApplication sharedApplication] delegate] window] addSubview:menuController];
The problem is, the view appears below the keyboard, which is already on screen. How do i fix this?
The easiest way to display some view on top of the keyboard is put that view inside a UIWindow for which you set the windowLevel property to UIWindowLevelAlert. Something like:
UIView *myView = [[UIView alloc] initWithFrame:rect];
UIWindow *myWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
myWindow.windowLevel = UIWindowLevelAlert;
[myWindow addSubview:myView];
[myWindow makeKeyAndVisible];
If you're using ARC, make sure you keep a strong reference to myWindow. Otherwise, it'll get automatically released and so it won't get added to your application windows.
(This is how UIActionSheet and UIAlertView work internally. When one of them is visible, have a look at [UIApplication sharedApplication].windows and you'll see they create windows with their windowLevel set to UIWindowLevelAlert.)
Ok it took awhile for me to understand what you wanted to do. You have 2 options.
Resign the keyboard and show the view with the buttons.
Use a UIActionSheet to display the buttons over the keyboard like it does in the Messages application when you press the camera to send a picture to someone.
I would recommend the later.
Edit:
Take a look at this for your custom UIActionSheet Show a view over the keyboard
The keyboard exists in its own window. To put things over it, you either have to put things into the keyboard's window (this is not a supported behavior), or create yet another window and put it over the keyboard.

Adding a splash screen to my project

I have created a project which consist of a tabbarcontroller and a navigationcontroller.
The first view or the first tab is a tableview controller. Now i need to add a splashscreen to my application, so when the app loads it will show a welcome screen and then land on the tableviewcontroller.
My workings so far;
This is added in my viewDidLoad method.
myImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"splash.jpg"]];
myImageView.frame = [[self view] frame];
[self.view addSubview:myImageView];
[self.view bringSubviewToFront:self.myImageView];
The problem is that the splash screen or the UIImageView loads inside the tabbarController/NavigationController, and it does not take the full width and length of the screen. What should i do to fix this programatically ?
In application bundle you need to copy the splash screen images with the name "Default.png" and "Default#2x.png" for Retina. The app will load this automatically, you don't need to do more work.
Here you have a link for this: http://iosdevelopertips.com/cocoa/defaultpng-the-secret-of-the-load-screen.html
Add the images that you want to use to the resources of your project and name them Default.png and Default#2x.png (if you are providing it for a retina screen). Be sure no name them exactly. If you get the capitalisation wrong, it will work in the Simulator (which is not case-sensitive), but not on the device (which is case-sensitive).
Be aware that a "splash screen" is discouraged by the Apple Human Interface Guidelines:
Have you given the Launch Images a look in your target settings?
You would probably want to add the splash screen in the app delegate's didFinishLaunchingWithOptions method. Then start an animation of fade out (or whatever animation you need). Finally removing the splash screen view when the animation is complete.
You have to add the UIImageView to the root's view:
UIView *rootView = [[[[UIApplication sharedApplication] delegate] viewController] view];
[myImageView setFrame:rootView.bounds];
[rootView addSubview:myImageView];
you can use the uiimage view to add an array of images to play an animation, try the following
code in
-(void)viewDidAppear:(BOOL)animated {
animationSplashImageView.animationImages = imageArray;
animationSplashImageView.animationDuration = 5;
animationSplashImageView.animationRepeatCount = 1;
[animationSplashImageView startAnimating];
}
IBOutlet UIImageView* animationSplashImageView;
was defined in the main view of your app.
also you could test your splash using tool Splashx Free, which is on Apple App Store: http://itunes.apple.com/cn/app/splashx-free/id500137095?mt=8

custom UINavigationBar background in MFMailComposeViewController

I have a need to use a custom background for the UINavigationBar in a MFMailComposeViewController. Previously I was using a category on UINavigationBar to achieve this throughout my app, but Apple specifically requests that you do not do this. Additionally this may or may not work in future versions of iOS that are currently under NDA.
I am now using a subclass of UINavigationBar to achieve the look I'm after in the rest of the app, but I can't see any way to use this with the MFMailComposeViewController. Any ideas?
Note: I'm aware of methods to do this in a future version of iOS, but this needs to be built against a current version (4.3) of the SDK.
I just ran across this -- you can dynamically inject the class a view controller uses using object_setClass.
#import <objc/runtime.h>
object_setClass(mailController.navigationBar, [YourNavigationBarSubClass class]);
You can customize the nav bar's titleView with a custom view using the code below. Expanding upon this idea, you may be able to resize the titleView to cover the entire navigation bar and use a custom background in that to simulate a custom navbar background.
The only possible sticky part I can think of is that you need to make sure the titleView sits behind the buttons in the toolbar.
Once you have your MFMailComposerViewController reference, here is the code to customize the titleView:
[self presentModalViewController:controller animated:YES];
UIView *backgroundView = [[UIView alloc] initWithFrame:CGRectMake(//set size to navbar size)];
[backgroundView setBackgroundColor:[UIColor colorWithPatternImage://your custom image ]];
controller.topViewController.navigationItem.titleView = backgroundView ;
[controller release];
The mail composition interface itself is not customizable and must not be modified by your application.
check apple reference for more info...
http://developer.apple.com/library/ios/#documentation/MessageUI/Reference/MFMailComposeViewController_class/Reference/Reference.html
but we can customizable the mail composition as given oin the above answer....
After some hacking and testing, still not manage to customize the button. But this is the closest I can get, by setting the tint color of mail controller.
Try accessing them through mailController.navigationBar.items, which is an array of the bar items.
MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
mailController.navigationBar.tintColor = [UIColor brownColor];
Although it would be nice to get more control over the appearance, I don't think there is a clean method. When you cant change it...hide it:
NSDictionary *attributes = #{NSForegroundColorAttributeName: [UIColor clearColor]};
[[UINavigationBar appearance] setTitleTextAttributes:attributes];

How can I display a introduction modal view when the app start up?

I have a tab bar application and I want to display those views that most part of apps have, with the name of the company or the name of the app.
I've created the follow viewController
Introduction *introducao = [[Introduction alloc] initWithNibName:#"Introduction" bundle:nil];
I don't know where exactly should I insert the code to show the modal because I have a tab bar application:
[self.navigationController presentModalViewController:galeria animated:YES];
I've tried to insert these lines on appDelegate.. but didn't work.. somebody have an idea?
if you are trying to show a splash screen right when the application opens, you should use a Default.png image instead of a view controller showing an image. Check out the Apple Documentation on Human Interface Guidelines and Beginning iPhone Development.
First of all, you'll need to ensure that you have a navigation controller present to present the model view from. Otherwise in the above code you'll be messaging nil and nothing will happen. Then you'll want to put the presentModalViewController:animated: call in your app delegate's applicationDidFinishLaunching: implementation.
Thanks for all answers.. they were very useful to understand better the process..
I have found a solution that does exactly what I need! So if someone need to create those splash screens with a sequence of images it is very useful:
Just create a ImageView on the Delegates Header and do the following:
splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
splashView.image = [UIImage imageNamed:#"Default.png"];
[window addSubview:splashView];
[window bringSubviewToFront:splashView];
to control the duration of the splash screen:
[self performSelector:#selector(removeSplash) withObject:nil afterDelay:1.5];
To remove the splash:
-(void)removeSplash;
{
[splashView removeFromSuperview];
[splashView release];
}
so If you want to create a sequence of image just create a method to change the splashView.image.. and create a NSTIMER to call it..

iPhone SDK 3.0 in-app email - changing navigation bar tint color

My App uses the iPhone SDK 3.0's new in-app email feature.
I want to change the tint color of the email UI to black and make it translucent.
I tried the following code,
/*
picker.navigationController.navigationBar.tintColor = [UIColor blackColor];
picker.navigationController.navigationBar.translucent = YES ;
*/
But it's changing the color of the view that creates,
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
the compose window, rather than the compose window itself.
Is this atleast possible? Or should we stick to Apple provided blue itself???
Since the MFMailComposeViewController is a subclass of UINavigationController, simply do this:
[[picker navigationBar] setTintColor:[UIColor redColor]];
The iPhone Human Interface Guidelines do not forbid to use custom colors but recommends the standard colors (blue and black).
Yes it is possible.
Just add a objective-c category in the UINavigationBar class overriding the drawInRect Method.
This way you can do want.
The disadvantage, all your navigation bars will change :)
[[picker navigationBar] setTintColor:[UIColor blackColor]];
....makes the Cancel and Send buttons black too. They are not blue and do not change color when pressed.
You can also try this code....
MFMailComposeViewController *mailComposeView = [[MFMailComposeViewController alloc] init];
mailComposeView.navigationBar.tintColor = [UIColor cyanColor];