I have implementing pdf application for ipad.Now i want to set brightness in my application.Is it possible?Please help me for this problem.
Thanks in advance.
Most applications that you see with this feature are putting up a full screen solid black view or window and adjusting the alpha level. The brightness is then adjusted from some minimum value to the current system maximum. The actual system brightness cannot be accessed by a sandboxed application.
UIWindow *shader = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds];
shader.backgroundColor = [UIColor blackColor];
shader.alpha = 0.1;
With a view, you have the option of being behind things like toolbars. With a window, you can be over everything if you set the window level high enough. Do not let the alpha level go above 0.5 or whatever you choose as your limit.
short answer: you can't in the official sdk.
Related
We have update our application to support both iPhone 4 and iPhone 5 screen size. It is working fine in both simulators but when we install it on iPhone 5 device then it behaves like iphone 4 application (Black borders on top and bottom). We have also added Default-568h#2x.png bot not working correctly. We are creating window dynamically.
What we are missing here ? Any ideas ?
Also how to set "Full Screen At Launch" property of UIWindow programmatically ?
Here is one solution that worked
A. In your AppDelegate.m initialize the UIWindow object like this
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]
B. In order to manage other UI Elements You can define a macro that provides current frame of the screen be it iPhone 4/iPhone 5
#define SCREEN_FRAME [[UIScreen mainScreen] applicationFrame]
Accordingly you can use SCREEN_FRAME width/height properties to adjust other UI elements
Hope this helps.
I am trying to update my App for the iPhone 5's larger screen real estate. I have a tableview that has expanded to take up the full height of the screen by adding the Default-568h#2x.png to my project, but the bottom couple of cells are not responding to touched in the simulator or the actual iPhone 5. Am I missing something? It's like the bottom portion of the screen is not detecting touched (but just in my App not the others).
Any thoughts?
Thanks,
Rob
This is whats working for me
In application didFinishLaunching method I added this -
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
In any other view controller, preferably in - (void)viewDidLoad;
UIScreen *screen = [UIScreen mainScreen];
[self.view setFrame:[screen applicationFrame]];
Yes may be your window frame size in AppDel class or in XIB file of your project's appdel class is not as per iPhone 5 Screen.
And change window frame according 3.5 inch and 4 inch screen of iPhone
As some of you may have noticed, most (if not all) of system apps show the screen with rounded corners. I mean, the four corners of the device screen look rounded.
However, most of third party apps don't (the corners are 90º), but I've seen some that do, as Facebook messenger. Many others have this effect but only on the splash screen (which may be only a modification to the default.png image file)
Is there a property to achieve this effect?
If you want the rounded corners over the ENTIRE app, and not have to explicitly recreate them with every different View Controller you want, call it in AppDelegate: (didFinishLaunching method)
[self.window.layer setCornerRadius:20.0];
[self.window.layer setMasksToBounds:YES];
self.window.layer.opaque = NO;
Don't forget to:
#import <QuartzCore/QuartzCore.h>
This way is better because it creates the animation on the WINDOW, and not the VIEW. So you can design the rest of the UI with 90˚ corners, and they'll automatically be rounded. It's much easier calling it once.
It also may be better for performance to rasterize the layer, especially if it lags:
[self.window.layer setShouldRasterize:YES];
[self.window.layer setRasterizationScale:[UIScreen mainScreen].scale];
The above will force the animation/graphic change to "act like an image" without making the UI too heavy. Performance will improve, and rasterize according to Retina or Non-Retina Screens. (This is the [UIScreen] call, as ".scale" returns 2.0 for retina, and 1.0 for non-retina. Very, very simple.
Hope this helped! Tick if so and I'll come back and see! :)
Following will round the corners of a view. You can put it in viewDidLoad:
#import <QuartzCore/QuartzCore.h>
view.layer.cornerRadius = 7;
// Import QuartzCore.h at the top of the file
#import <QuartzCore/QuartzCore.h>
self.view.layer.backgroundColor = [UIColor orangeColor].CGColor;
self.view.layer.cornerRadius = 20.0;
self.view.layer.frame = CGRectInset(self.view.layer.frame, 20, 20);
Check out the Introduction to CALayers Tutorial. You will get good start up.
#PsycoDad: This addition to #cocotouch's answer fixed the top part of the screen
CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
CGRect screenBounds = [[UIScreen mainScreen] bounds];
self.window.layer.frame = self.window.layer.bounds =
CGRectMake(0,
statusBarHeight,
screenBounds.size.width,
screenBounds.size.height - statusBarHeight);
On iOS 5 with an iPad 2 or iPhone 4S, users can enable screen mirroring with their Apple TV and AirPlay. How can I prevent my app from being mirrored in this way? Is there any way to detect that this mirroring is taking place so I can prevent my content from being mirrored?
The reason for doing this is because I have content I'm not legally allowed to display on a television screen.
This is a really really bad idea and I hate it as you are inhibiting your users. With that said, AirPlay mirroring works the same way as connecting the VGA/HDMI adapter, when you connect an adapter you have the ability to display whatever you want on the "second monitor". If you want to "block" mirroring you could set the external display's window to a blank/solid black view.
Most iOS applications create and use only one window during their lifetime. This window spans the entire main screen of the device and is loaded from the application’s main nib file (or created programmatically) early in the life of the application. However, if an application supports the use of an external display for video out, it can create an additional window to display content on that external display. All other windows are typically created by the system, and are usually created in response to specific events, such as an incoming phone call.
Check out the View Programming Guide for iOS, specifically the Windows section and Displaying Content on an External Display
Just to add the code for doing this pretty simple work Here
if ([[UIScreen screens] count] > 1)
{
UIScreen *secondScreen = [[UIScreen screens] objectAtIndex:1];
CGRect screenBounds = secondScreen.bounds;
UIWindow *secondWindow = [[UIWindow alloc]initWithFrame:screenBounds];
secondWindow.screen = secondScreen;
UIView *anyView= [[UIView alloc]initWithFrame:screenBounds];
anyView.backgroundColor= [UIColor blackColor];
[secondWindow addSubview:anyView];
}
Which approach is good to create universal native application for iPhone/iPad:
1) Create separate NIB files for iphone and iPad versions and load the specific version by checking (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad).
2) Get the dimension of the main screen and frame the view accordingly
CGRect mainWindow = [[UIScreen mainScreen] bounds];
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, mainWindow.size.width, mainWindow.size.height)];
Please suggest if any other approach that I missed
Thanks,
Ajay
I am using the first approach, in many cases, at least for my own it is sufficient to set autoresizing masks. You have not said anything about this, but if your application will look pretty much the same (up-scaled layout) this works fine. In the cases I need another layout I have checked whether it is an iPad/iPhone and loaded the correct NIB, or used the GUI code in loadView based on the device.
From you example code with the webview you could use autoresizing masks and it would resize to the correct proportions when the frame changes.