Fixed UIImage PushViewController animated - objective-c

I want to get an image fixed between the animation, so it doesn't move when the app slides to right. A bit like the background of a UINavBar, I couldn't find anyone who tried it earlier so I would really like to know.
Thanks in advance
Sjors

As a response on your last comment, here is how to do this:
UIView * hoi = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
hoi.backgroundColor = [UIColor blackColor];
UIWindow * window = [UIApplication sharedApplication].keyWindow;
[window addSubview:hoi];
Alternatively you create add a second UIWindow to which you can add your subviews. As is nicely explained in this answer: https://stackoverflow.com/a/2671148/262691

Related

How to create a 45 degree Askew or skew element in objective-c?

I want to create any (particularly uiview) kind of element (uiimageview, uibutton, uilabel etc.,) that should be in askew or skew style.
Is that possible in xcode - objective-c?
If you want deep explanation:
1) go to google.com and search ASKEW or click here
2) like italic fonts
Advance thanks :)
UPDATED # 21/12/2015
I found uibezierpath that allow you to draw point to point if anyone know to draw uibezierpath add that answer in comment field.
You can have this view inside a askew view like this:
UIView *askewView = [[UIView alloc] initWithFrame:self.view.bounds];
UIView *exampleView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
exampleView.backgroundColor = [UIColor redColor];
[askewView addSubview:exampleView];
askewView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:askewView];
CGAffineTransform transform = CGAffineTransformRotate(askewView.transform, 0.1);//M_PI/4);
askewView.transform = transform;
I used 0.1 radians because I think that 45º is to much, but in comment have the PI/4 (45º).
Result:
I hope this can help you.

How to disable Preview screen when using UIImagePickerController Camera

In iOS7 the build-in camera app doesn't go into the preview screen after taking a picture, is there any way that the UIImagePicker can behave like that.
UIImagePickerController * imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;
I know another solution is to create a custom camera using the AVFoundation class, but that is beyond my knowledge at this point and I really like the looks of the default camera.
Update
So after some more research I found out I could create my own shutter button and set it as a camera overlay. Here is what I did
UIButton *shutter = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[shutter addTarget:self action:#selector(shootPicture) forControlEvents:UIControlEventTouchUpInside];
[shutter setTitle:#"S" forState:UIControlStateNormal];
shutter.frame = CGRectMake(50, 50, 60, 60);
UIView *layoutView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
layoutView.opaque = NO;
layoutView.backgroundColor = [UIColor clearColor];
[layoutView addSubview:shutter];
For the 'shootPicture' method
- (void) shootPicture
{
[picker takePicture];
[self imagePickerController:self.camCtl didFinishPickingMediaWithInfo:nil];
}
If I just have the picker call 'takePicture' I will still get the preview, so instead I forced the picker to call didFinishPickingMediaWithInfo right after taking picture. The result is I don't see the preview screen HOWEVER I don't see the picture either. I know I put 'nil' in didFinishPickingMediaWithInfo because I don't know what to put in at this point. I also know it took a picture is in cache somewhere but I really have no idea how to get it.
Any idea would be greatly appreciated =)
This solution works for me:
self.pickerController.allowsEditing = false

How Do I dim/disable the current view?

Is it possible to dim the current view in cocoa?On a certain action I want to make the screen a little darker and prevent the user from interacting with the screen.
From the idea given by #Lord Zsolt, the same can be implemented in OS X as:
Add the following code when you want to darken your window.
NSView *transparentBlackView = [[NSView alloc] initWithFrame:[[yourwindow contentView] frame]];
CALayer *viewLayer = [CALayer layer];
[viewLayer setBackgroundColor:CGColorCreateGenericRGB(0.0, 0.0, 0.0, 0.4)]; //RGB plus Alpha Channel
[transparentBlackView setWantsLayer:YES];
[transparentBlackView setLayer:viewLayer];
[[yourwindow contentView] addSubview:transparentBlackView];
Also don't forget to add QuartzCore.framework to your project. And import it in your class using #import<QuartzCore/QuartzCore.h>
Edit: I've only now noticed, it's OSX, not iOS. Though the idea should still be the same.
Disable user interaction:
[self.view setUserIntractionEnabled:NO];
Then add a UIView with black color, alpha like 0.2 above it.
UIView *transparentBlackView = [[UIView alloc] initWithFrame:self.view.frame]
[transparentBlackView setBackgroundColor:[UIColor blackColor];
[transparentBlackView setAlpha:0.2];
[self.view addSubview:transparentBlackView];
Then you can write a custom method, and use performSelector:afterDelay to remove transparentBlackView.

Why UIActivityIndicatorView is not showing on UIWebView?

Code:
CGPoint centerPoint = [_inner_web_view center];
CGRect frame = CGRectMake(centerPoint.x, centerPoint.y, 100, 100);
_activity_indicator = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
[_activity_indicator setFrame:frame];
[_inner_web_view addSubview:_activity_indicator];
What I need is to display ActivityIndicator on UIWebView.
Even after using [_activity_indicator startAnimating] nothing happens. :(
Can someone help me find out WHY this happens?
Your Activity Indicator View's Style is White UIActivityIndicatorViewStyleWhite and UIWebView also has white background when loading. Try Gray Style UIActivityIndicatorViewStyleGray.

UINavigationBar custom title being hidden by background

I am adding a custom UIImageView to my UINavigationBar using this code:
UIImageView *background = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)] autorelease];
[background setImage:[UIImage imageNamed:#"nav_background.png"]];
[background setTag:kTagForReference];
[self.navigationController.navigationBar insertSubview:background atIndex:0];
I then add a custom title using this code:
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 400, 44)];
...
[self.navigationItem setTitleView:label];
[label release];
But on some of my pushed views the title is being hidden (or isn't visible). I can't seem to push more than two views onto the stack without the title disappearing.
I've tried to force my UIImageView background to the back of the bar but that still doesn't help. I've printed the subviews of the UINavigationBar and I can see that the UILabel is there, I just can't see it!
Any help would be greatly appreciated.
If you can run the dumpWindows() function, the output would show the view hierarchy so you can see what view is covering it up.
You most likely want to use a UIToolBar instead of a NavigationBar. Then you can add the subviews to the UIToolbar.
Bring the UILabel to the front most view.
[self.view bringSubviewToFront: label];