Permalink
Browse files

Added cam thing tester for modal popovers on iPhone.

  • Loading branch information...
1 parent a65fd0e commit 91e561767f40d6e5c730257a9c10b6486ea9b793 @Inferis Inferis committed Jan 14, 2012
Showing with 21 additions and 9 deletions.
  1. +0 −8 ViewDeckExample/AppDelegate.m
  2. +1 −0 ViewDeckExample/ViewController.h
  3. +20 −1 ViewDeckExample/ViewController.m
@@ -32,14 +32,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
rightViewController:rightController];
deckController.rightLedge = 100;
- if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
- }
- else {
-
- }
-
-
-
self.window.rootViewController = deckController;
[self.window makeKeyAndVisible];
return YES;
@@ -8,4 +8,5 @@
@interface ViewController : UITableViewController
+@property (nonatomic, retain) UIPopoverController* popoverController;
@end
@@ -8,6 +8,8 @@
@implementation ViewController
+@synthesize popoverController = _popoverController2;
+
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
@@ -32,7 +34,10 @@ - (void)viewDidLoad
[super viewDidLoad];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"left" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(toggleLeftView)];
- self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"right" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(toggleRightView)];
+ self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:
+ [[UIBarButtonItem alloc] initWithTitle:@"right" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(toggleRightView)],
+ [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(showCam:)],
+ nil];
}
- (void)viewDidUnload
@@ -68,6 +73,20 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
return YES;
}
+- (void)showCam:(id)sender {
+ UIImagePickerController* picker = [[UIImagePickerController alloc] init];
+ if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
+ picker.sourceType = UIImagePickerControllerSourceTypeCamera;
+
+ if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
+ self.popoverController = [[UIPopoverController alloc] initWithContentViewController:picker];
+ [self.popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
+ }
+ else {
+ [self presentModalViewController:picker animated:YES];
+ }
+}
+
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

0 comments on commit 91e5617

Please sign in to comment.