WebKit Viewport
Viewport tag to allow web content to work on both the iPhone and the iPad. The tag adjusts the viewport to the width to the device. Handy little webkit tag.
<meta name="viewport" content="width=device-width" />
Viewport tag to allow web content to work on both the iPhone and the iPad. The tag adjusts the viewport to the width to the device. Handy little webkit tag.
<meta name="viewport" content="width=device-width" />
Shake reset. Actually the snippet really just for responding to a shake motion. The snippet was used to reset an image, but can be changed out to respond to anything. Another objective-c snip. There a comment in the block of code below where the change can occur.
--
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
}
// Shaking here resets an image but it can do anything, just change out self
// resetImage to something else.
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if (motion = UIEventSubtypeMotionShake ) {
[self resetImage];
}
}
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event {
}
A little snip for creating an image from an UIView. Much like a snapshot from an view or rect. and exports new image to the photo album.
#import <QuartzCore/QuartzCore.h>
- (UIImage*)captureView:(UIView *)view {
CGRect rect = [[UIScreen mainScreen] bounds];
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[view.layer renderInContext:context];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
- (void)saveScreenshotToPhotosAlbum:(UIView *)view {
UIImageWriteToSavedPhotosAlbum([self captureView:view], nil, nil, nil);
}
Filling a snippet app with bits of code for reuse, is always helpful. I am not always on the same machine and when I need just to reuse or look at a past example how I did something before. That sucks when that happens. Then an idea hit me, why not just make the snippets public. I got started from other people snippets and well I really see no harm in making a snippet that sits in my snippet app available here. Sure there sites for code sharing but why bother when posterous has made every thing so simple publish a post from anywhere. This is just stuff I have sitting around now, I not going to go out of my way and post anything I do not use or plan to use. That may be limiting cause I only use a very limited set of languages. And I sure I well not post them if I not looking that them, when feel the graces of sharing.
As a snippet just a small piece to finishing a larger puzzle. Yes I threat this all as if I was playing a puzzle game, because that what makes it fun for me to do this kind of stuff. I know that sounds crazy but I do not really care what someone else thinks about my motivation to do something.