iPhone: rotate the UIImageView inside a UIButton (Weird effect) - objective-c

My problem is that I want to rotate the UIImageView of a UIButton.
The transformation itself is pretty easy:
super.imageView.transform = CGAffineTransformMakeRotation((M_PI*120)/180);
(I subclass a button, but it doesn't work with a normal button either.)
So, it rotates but looks not very pretty: http://img534.imageshack.us/img534/2796/afterh.png
As reference, this is the same imageView but not rotated:
http:// img704.imageshack.us/img704/1299/beforen.png (sorry for that whitespace, I'm new and can just post one link...)
Thanks for your help
Sebastian

Okay, i finally got it.
It was needed to set the clipsToBounds property of the imageView to NO.
Sebstian

Related

uibutton image not shown in simulator

I a trying to do an uibutton with image and text, in xib it looks fine but in the simulator the image is missing, and I don't know why.
xib:
the uibutton settings:
the look in simulator:
Simple way is to take UIView and add UIImageView,UILabel as SubView using interface builder. Then add a transparent button all over the UIView. I hope your problem will be solved.

Show UIImageView in front of UIView

Is there a way to show a UIImageView in front of a UIView (for Preview live)?
I try to make a camera based application so when clicking on a button the app take a pic and show it into UIImageView.
[myView addSubview: myImageView]
should work fine. if not please post your code.
If you are adding the view programmatically the previous suggestion should do it. If the views are in a storyboard or XIB and you want to move it to the front, try this:
[self.view bringSubViewToFront:myImageView];
You might want to use UIKit Peek and Pop if you are on iOS 9 or above.
Also there is this tutorial: http://useyourloaf.com/blog/3d-touch-peek-and-pop/

How to disable touch detection on a UIImage?

I am working on an app, which actually works like MSPaint (something to draw lines, etc...).
I got a white UIView, basically where the user draws. On top of this UIView I set up a UIImage, which is gray, with a 0,4 alpha. I want this UIImage to be used as a blotting paper. The idea is to disable touch when the user put the palm of his hand on this area, so it's more comfortable to draw (multitouch is disabled, and with this "blotting paper" you won't draw something accidentally with your palm...)
Even if I bring the UIImage to the front, on top of the view, and even if I disable user interactions on this UIImage, it is still possible to draw on the UIView. , behind the UIImage (kind of strange!)
I do not understand what's happening, because, it seems that the image is transparent, and that the UIView "behind" is still active, even if she's overlaid by the UIImage?!
Any help/indication/idea would be much appreciated! Thank you :-)
Have you set the "userInteractionEnabled" property of the UIImage to "NO" ?
You may actually want to do the opposite. When you disable user interaction or touches, the view basically becomes invisible to touches and they are passed on to the next view.
In your case you do want userInteractionEnabled because you want the view to catch those touches.
You have to disable the user interaction on the UIImageView not the UIImage and it should work.
Edit:
Or you could be sneaky and just add an empty view over it. Use the same frame size so it overlaps perfectly and thats it. You'll be able to see everything you need and it's not a subview of it so there will eb no interaction and touches will get registered but won't have any effect. :P
No better ideas unless you post some of your code...
OK, so I managed to do what I wanted to! YAY!
I got 3 different classes :
StrokesViewController (UIViewController)-the view controller
StrokesView (UIView) - the view where the user draws the strokes.
BlottingPaper (UIView) - the blotting paper.
I got a XIB file "linked" to all three.
I created this new class, called "BlottingPaper", typed UIView. the .h and .m file are actually empty (I do import #import < Foundation/Foundation.h >)
User interaction is enable on BlottingPaper.
I do not use the exclusive touch on this class.
On the XIB file, I just put a view on top of StrokesView. I link it to BlottingPaper (modify the alpha as I want, blablabla...)
And that's it! When I put the palm of my hand on it, it doesn't draw anything on the area where my hand is, but I still can draw with my finger on the rest of the StrokesView!
In addition to Dancreek's response, you should be setting buvard.userInteractionEnabled = YES; so that it captures interaction.
You should also set buvard.exclusiveTouch = YES; so that buvard is the only view which will receive touch events.
When you remove buvard you should set buvard.exclusiveTouch = NO; so that other views will regain their ability to receive touches.

Cause UIScrollView zoomToRect: to only display a portion

I have a UIScrollView subclass that contains a UIImageView. When the user double taps on the zone I want to zoom to that CGRect (calculated from CGPoint) and "hide" the rest of the UIImageView. The final effect is similar in Mavel.app and The Walking Dead.app when you are reading a comic.
Until now I got:
-(void)presentRect:(CGRect)rect {
self.bounds = originalFrame; //1
[UIView beginAnimations:#"navigateToPos" context:nil];
[self zoomToRect:rect animated:NO];
self.bounds = rect;
[UIView commitAnimations];
}
This works, but "zoomToRect" needs the whole bounds of the UIScrollView and when I restart it (line 1), it gives an undesired effect.
I am stuck with this. I don't know if I need a new approach or need to use another property of UIScrollView.
Any help is appreciated. Thanks.
I downloaded this apps to see it. I'm almost sure they didn't even use uiscrollview. The way the pages moves make me think about that. And uiscrollview should be used only when you really need it, because it have a lot issues when you're customizing. (tiled content, zooming and others problems).
Slide to a next page only 50px aprox., the page goes to the next, in uiscrollview it didn't happen because it works diff.
As I said before, probably it's made using 4 bars (as you correct me) or it can be done with a view wrapping the uiimage and working as a mask. You only need calculate the size of the zoom square and move it to center, and resize the wrapper view to fit this new size. The substitute for the uiscrollview for pages can be a simple image gallery, but where is images you put this "comic-view".
I've solved using other properies from UIScrollView simulating the desired effect.

Keeping UIButton Stationary on Screen

I have a UIButton on top of a UIWebView. The UIButton is supposed to look like it's native to the webpage. However, when I zoom in on the UIWebView, the button comes with it, obviously looking out of place. Is there a way to keep the button's position relative to the UIWebView rather than its position on screen?
Thanks for any help!
Not sure I've understood your problem, but here goes:
You've likely a view hierarchy like this:
View
UIWebView
UIButton
That is, your button was added as subview to the UIWebView. Since the UIWebView is also a UIScrollView you get the behavior you've observed. To fix it, make the button a sibling, not a child:
View
UIWebView
UIButton
It will still be drawn in front of your UIWebView if it was added after the UIWebView.