How to use UIImagePickerController in iPad?

UIImagePickerController must be presented with UIPopoverController on iPad. if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker]; [popover presentPopoverFromRect:self.selectedImageView.bounds inView:self.selectedImageView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; self.popOver = popover; } else { [self presentModalViewController:picker animated:YES]; } EDIT: Add a strong property for the UIPopoverController: @property (nonatomic, strong) UIPopoverController *popOver; The popover should be dismissed in … Read more

UIView subclass with its own XIB [duplicate]

ThomasM, We had similar ideas about encapsulating behavior inside a custom view (say, a slider with companion labels for min/max/current values, with value-changed events also handled by the control internally). In our current best-practice, we would design the ShareView in Interface Builder (ShareView.xib), as described by Eimantas in his answer. We then embed the ShareView … Read more

Bonjour over bluetooth WITHOUT Gamekit ?

Just announce the service, just like tc. has said below: self.netService = [[[NSNetService alloc] initWithDomain:@”” type:@”_http._tcp” name:@”” port:8080] autorelease]; [self.netService publish]; With iOS5, however, let’s-call-it “Bluetooth Bonjour” is disabled by default, so you have to use the C API declared in <dns_sd.h>. DNSServiceRef serviceRef; DNSServiceRegister(&serviceRef, // sdRef kDNSServiceFlagsIncludeP2P, // interfaceIndex 0, // flags NULL, // … Read more

SQLite database on PhoneGap

We ended up using the PhoneGap SQLite plugin, here’s why: We started off using a plain old Web SQL Database in our PhoneGap app, but ran into the following limitations: Size of database is limited to 5MB (the user can be prompted to allow more, but we didn’t want such prompts in our app) Pre-populating … Read more

Web site exhibits JavaScript error on iPad / iPhone under 3G but not under WiFi

I’ve investigated this further and discovered that the problem is that the UK mobile operator O2 (the original exclusive iPhone operator for Apple), modifies web content before sending it to iPhones and iPads. Probably before sending it to any device running a mobile browser. They non-deterministically inline some of the CSS and JavaScript into the … Read more

Interface orientation in iOS 6.0

Deprecated method in iOS 5: // Override to allow orientations other than the default portrait orientation. – (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); } Replacement in iOS 6 and equivalent of this deprecated iOS 5 method above: – (BOOL) shouldAutorotate { return YES; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscapeRight; } … Read more

image compression by size – iPhone SDK

Heres some example code that will attempt to compress an image for you so that it doesn’t exceed either a max compression or maximum file size CGFloat compression = 0.9f; CGFloat maxCompression = 0.1f; int maxFileSize = 250*1024; NSData *imageData = UIImageJPEGRepresentation(yourImage, compression); while ([imageData length] > maxFileSize && compression > maxCompression) { compression -= … Read more

Make Background of UIView a Gradient Without Sub Classing

You can use +[UIColor colorWithPatternImage:] to produce a patterned background. Example (bring your own CGGradient): // Allocate color space CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); // Allocate bitmap context CGContextRef bitmapContext = CGBitmapContextCreate(NULL, 320, 480, 8, 4 * 320, colorSpace, kCGImageAlphaNoneSkipFirst); //allocate myGradient CGFloat locationList[] = {0.0f, 1.0f}; CGFloat colorList[] = {0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, … Read more

iOS multitasking for an Audio Recording application

You can. Skype does this. You presumably need to set <key>UIBackgroundModes</key><array><string>audio</string></array> in Info.plist, and you need to make sure that the audio session is active/running/whatever before you switch apps (the assumption is that you won’t suddenly start recording/playing music/whatever when your app is in the background). The docs say that “audio” lets you play audio … Read more