Disable whole UIView - ios

My app needs to save an image to disk. I do this in a separate thread, so the UI is still responsive, BUT, I do not want the user to add a new image until the first one is saved (about 1 second.)
At the moment, I'm disabling the 'take another picture' button and greying it out, but I'm wondering if there is a method that will disable the whole view, greying out the buttons and darkening the background, like what happens when a UIActionSheet is presented.
I've looked through the UIView docs and don't see anything like this, but it seems like such a useful pattern that is frequently used by Apple that I figured I'd ask, just in case there was such a thing.
Obviously I could do it manually, but why reinvent the wheel if its already part of the API.
TIA: John

set whatever view (main view, subview, etc.) you want to appear disabled to
view.userInteractionEnabled = NO
and also
view.alpha = 0.3f
and maybe even
view.backgroundColor = [UIColor grayColor]
to boot. These last two can be animated, b.t.w.

Present another view with the shadow and the gradient etcetera over this view thus giving it an effect of graying out with shadows. You may even create an image if you know your photoshop. Just show that image on a UIImageView over this view to be blocked. Give the image some nice translucency, shadows etc etc

Related

Place image on top of all "layers" on iOS screen

What are the constraints/alternatives to place an image that stays on top of all iOS "layers" and windows. Think of it as a lock screen but that still allows you to interact with you phone, meaning browse, answer calls, etc. The image will be displayed in a transparent way (say 40%) and will be launched by an application.
Not really sure what you are asking for but if you are looking for a way to add some code once and it shows everywhere on each of your ViewController then there really is no way to do that.
What you can do is
Use UIToolBar
add buttons to that tool bar
Add that tool bar to each ViewController in storyboard (where you need them)
Create a global function / method that you can call in from any ViewController that has the button actions in it. That way you edit the code once in one place and use it every where.
If you don't like UIToolBar then
you can add your own UIImageView and add a transparent background to it
Add your buttons on the UIImageView. (You will have to add constraints)
then show that on every ViewController
If all this seems to much work then you can use existing controls HERE and see which one fits your needs.
This maybe a good one - FCVerticalMenu

Xcode disable UIButton title fade when tapped

When I tap or hold down on any of my UIButtons, their alpha seems to fade to about 0.1. I never added this functionality in, so I'm assuming it's automatic.
How do I disable this so that my button doesn't fade when tapped or held down? I want my button to remain at alpha 1 all the time.
I've tried button.adjustsImageWhenHighlighted = NO; to no avail, as well as a few other suggestions on here.
Did you try using the same image for both the "normal" and "highlighted" states?
Maybe showsTouchWhenHighlighted also affects the situation.
Are you using background images for your buttons too?
Are you disabling the button upon tapping? Disabling also affects appearance (unlike userInteractionEnabled).
Are you using IB/Storyboards?
As you can see, there is a number of factors that can play a role into what's happening.
Any code you can show with specifics of your situation?
Edit: If you are not using an image (you mentioned adjustsImageWhenHighlighted), then just set the button type to "custom" in IB. You won't get the system provided "default" behavior.
just uptick the Disabled Adjusts Image in your MainStory Board in your buttons configuration next to the Drawing section

proper way to set background image to IPad App

I have a working IPad App. I built everything on a default white screen and I want to add an image to background of the image. I read a couple of articles and most of the suggest to create a new UIImage with the background image and stretch it to the full screen. I tried that but I am using a couple UIImage to display the photos taken and my UIImage s seem to stay at the back of the background and they don't get shown.
What is the proper way to set the background of IPad App?
this is the screenshot of my IPad App
Follow these steps :
1) Add UIImageView to your UIView.
2) Fill it with your Background UIImage.
3) Select your Background UIImageView and Select "Send to Back" Option....
The key is your view hierarchy. If you do not want to hassle around with moving the subviews along and sendings ome to back and some to front, then start with a proper view hierarchy from the beginning.
Basic rules are: the subviews overlay their superviews.
If siblings overlay each other, then the last one added is shown.
Your view hierarchy could be:
\UIView (A: the underlying self.view from the view controller's point of view.)
\UIImageView (B: the view for your background image. Empty or hidden from start.)
\UIView (C: Container for all of your views, no background color, no background image)
\UIImageView (C1: One of your picuters)
\UIImageView (C2: One of your picuters)
\UIImageView (C3: One of your picuters)
\UILabel (C4: One of your labels)
\ ...
Build up your view hierarchy. And when you need to add or change the background then assign the appropriate UIImage ot the View B.
Certainly, there is more than one way to achieve this. However, I personally thinkthat some proper view hierarchy works best, regardless whether you do that in IB or programmatically.
The proper way is to create a UIImageView and set it to the size of your view, and put all the others View in fron of it. The tutorials that you read are giving you the right way.
If you do not want to add an image, only a color you can set the background color of your view to this color.
You can use this code to send the ImageView to the back:
[self.view sendSubviewToBack:YouBackgroundImageView];
EDIT
Because you posted and XIB screenshot:
Your background image view must be in the first position, like this image:

Set background texture for my iphone app UIView

I am newbi to iphone apps as well as to this forum.
I want to place a background texture for my UIView that should cover the whole iPhone screen. I have controls placed on this view currently. Later on, I would like all my controls to be transparent, so user must be able to work with controls, but not see anything except its text.
Here is what I tried:
Created a UIView derived view - with simple background color, no image
Placed my controls - UIButtons, labels
Programmed all of them correctly to reflect my game logic
Now I have a change of my mind. I think its lot better to have a background texture for my view, as well as controls.
1) I tried things mentioned at: Adding A Background Image In Interface Builder
but this covers my UI controls.
2) Through Interface builder, I tried drag-dropping the texture image onto my view (which in turn, probably, created a UIImageview with background image = my texture). But that again hid every of my past work.
Then I started playing with alpha value (0.1, 0.8 etc) - it gives me some result, but I am no longer able to design my controls. Nor I am able to click (=touch) them at runtime anymore.
Please give me a method that will not disrupt my work so far (I hate redoing all the outlet wiring of my controls), but still allow me to achieve my goal.
Forgive me if I asked too silly thing, or did not search enough. This is my first question, and will be glad to try any helpful solution!
Many thanks!
How about:
self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:#"texture.png"]];

how to add the dimmed background found in UIAlertView

Im making a custom dialog thats similar to UIAlertView, and was wondering if anyone had any ideas how I can emulate the dimming background as in the photo below.
I agree that you should be very careful to have a real justification for redoing something that is already there, but if you really need it, it's easy:
Create a PNG image with the same size as the targeted device's screen, with alpha. TFill the image black, and add a radial opacity gradient, so that in the center, it is relatively transparent, while towards the screen edges it'll be more opqaue. This effect is called vignetting. Maybe there even is a vignetting filter on your preferred image editor, which you could use on a completely transparent image.
This image approach also has the benefit of allowing you to use completely different effects of fading away the background.
Create a UIImageView with the vignette image, and transparent background. Add the view to your app's Window, on top of all other views, but below your alertView:
UIImageView *vignetteView = [[UIImageView alloc] initWithImage: [UIImage imageNamed:#"vignette.png"]];
vignetteView.backgroundColor = [UIColor clearColor];
vignetteView.userInteractionEnabled = YES; //this means users won't be able to touch the UI elements below
[self.view.window insertSubview: vignetteView belowSubview: myAlertView];
First off, I'd recommend that you do your best to avoid the need for a custom modal dialog. You can usually give your feedback contextually within the flow of your application's actual views.
If your app targets iOS 5 only, UIAlertView offers three new styles to allow text input, secure text input, or a user name and password combo.
If you still need a custom modal alert, and you're looking to stay consistent with the iOS look and feel, and maintain resolution independence, I'd recommend that you avoid using static graphical assets. Instead, take the (somewhat hackish) approach of subclassing UIAlertView, and adding your own controls to it. You can find examples of doing this here and here.

Resources