PopOverController parsing value or array in UIPopupViewController class - ios

I have one calendar and some events in calendar.
When user click on event date then open popup, I know how to show popup, but problem is how to parsing table data in my popup class xib ?
Here is my code I get a null value.
Here is code for click on event then show popup.
Here I pass a array in popupController movies.listOfEvent=listOfEvent; movies.listofEvent this is declared in calendarpopupviewController.
NSMutableArray *listOfEvent=[[NSMutableArray alloc] init];
for (int i=0; i<getEventData.count; i++)
{
[listOfEvent addObject:[getEventData objectAtIndex:i]];
}
NSLog(#"%#",listOfEvent);
if (self.popoverController == nil)
{
CalendarPopupViewController *movies = [[CalendarPopupViewController alloc] initWithNibName:#"CalendarPopupViewController" bundle:[NSBundle mainBundle]];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:movies];
movies.getValue=#"nishant------------";
movies.listOfEvent=listOfEvent;
popover.delegate = self;
self.popoverController = popover;
}
CGRect popoverRect = getPoint;
popoverRect.size.width = MIN(popoverRect.size.width, 100);
[self.popoverController presentPopoverFromRect:popoverRect
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
Where do I mistake, how to pass value ? please help me
In my popupviewController code
#interface CalendarPopupViewController : UIViewController<UITableViewDataSource,UITableViewDelegate>
#property (nonatomic,strong) NSArray *listOfEvent;
#property (strong,nonatomic) NSString *getValue;
and .m file
#synthesize listOfEvent;
#synthesize getValue;
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(#"%#",getValue);
NSLog(#"%#",listOfEvent);
}

Related

How to use CAPSPageMenu source for Objc?

I am developing IOS project using objective C.
I am going to make sliding tab page.
I found this source from github.
https://github.com/PageMenu/PageMenu
This is the source code which I use CAPSPageMenu.
When
#interface BusinessTabViewController ()
#property(nonatomic) CAPSPageMenu* pageMenu;
#end
#implementation BusinessTabViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSMutableArray *controllerArray = [NSMutableArray array];
UIViewController*controller = [[UIViewController alloc] initWithNibName:#"GongsiyingyeViewController" bundle:nil];
controller.title = #"Sample title";
[controllerArray addObject:controller];
NSDictionary *parameteres = #{CAPSPageMenuOptionMenuItemSeparatorWidth:#(4.3), CAPSPageMenuOptionUseMenuLikeSegmentedControl:#(YES), CAPSPageMenuOptionMenuItemSeparatorPercentageHeight:#(0.1)};
_pageMenu = [[CAPSPageMenu alloc] initWithViewControllers:controllerArray frame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) options:parameteres];
[self.view addSubview:_pageMenu.view];
}
It shows only white screen.
Please help.
Thanks.
The error is not related with PageMenu, Comment the code for Registering Push Notification then try it.
And Before pushing a viewcontroller check that viewcontroller is nil or not.
CAPSPageMenu is working fine in our project.
#interface BusinessTabViewController ()
#property(nonatomic) CAPSPageMenu* pageMenu;
#end
#implementation BusinessTabViewController
-(void) viewDidLayoutSubviews{
NSMutableArray *controllerArray = [NSMutableArray array];
UIViewController*controller = [[UIViewController alloc] initWithNibName:nil bundle:nil];
controller.title = #"Sample title1";
UIViewController*controller1 = [[UIViewController alloc] initWithNibName:nil bundle:nil];
controller1.title = #"Sample title2";
UIViewController*controller2 = [[UIViewController alloc] initWithNibName:nil bundle:nil];
controller2.title = #"Sample title3";
[controllerArray addObject:controller];
[controllerArray addObject:controller1];
[controllerArray addObject:controller2];
NSDictionary *parameteres = #{
CAPSPageMenuOptionMenuItemSeparatorWidth:#(4.3),
CAPSPageMenuOptionUseMenuLikeSegmentedControl:#(YES),
CAPSPageMenuOptionMenuItemSeparatorPercentageHeight:#(0.1),
CAPSPageMenuOptionMenuHeight:#(40),
CAPSPageMenuOptionMenuMargin:#(20),
CAPSPageMenuOptionSelectionIndicatorHeight:#(2.0)
};
_pageMenu = [[CAPSPageMenu alloc] initWithViewControllers:controllerArray frame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) options:parameteres];
[self.view addSubview:_pageMenu.view];
}
I use viewDidLayoutSubviews() for get accurate the size of frame.
It is working fine.

UIDatePicker memory leak in IOS 8.3

I am seeing memory leaks in UIDatePicker when used in a popover on an iPad running IOS 8.3. I'm getting approx 5K in multiple memory leaks every time the date picker is popped up and then dismissed. The leaked object is NSDateComponents, and the responsible frame is [_UIDatePickerMode _yearlessYearForMonth:].
I have written a simple test app to demonstrate the problem (https://github.com/david-ape/datepickertest/). I've included both a UIPopoverController option and a UIPopoverPresentationController option, but it doesn't seem to matter which is used.
Am I doing something wrong, or is there a workaround, or do I need to wait for a fix from Apple? If the latter, then can anyone suggest a third party control that I could use in place of UIDatePicker?
Below is the code I'm using to pop up the date pickers.
Header file
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController <UIPopoverControllerDelegate,
UIPopoverPresentationControllerDelegate>
#end
Implementation file
#import "ViewController.h"
#interface ViewController ()
#property (nonatomic, strong) UIPopoverController *ios7Popover;
- (IBAction)datePickerPopupIOS7:(UIButton *)sender;
- (IBAction)datePickerPopupIOS8:(UIButton *)sender;
#end
#implementation ViewController
// helper - returns a view controller containing a date picker for use in a
// popup
+ (UIViewController *)buildDatePickerViewController
{
CGRect frame = CGRectMake(0, 0, 350, 216);
UIViewController *viewController = [[UIViewController alloc]init];
viewController.preferredContentSize = frame.size;
UIDatePicker *datepicker = [[UIDatePicker alloc]initWithFrame:frame];
datepicker.datePickerMode = UIDatePickerModeDate;
datepicker.hidden = NO;
datepicker.date = [NSDate date];
[viewController.view addSubview:datepicker];
return viewController;
}
// popup date picker using UIPopoverController (IOS7 compatible)
- (IBAction)datePickerPopupIOS7:(UIButton *)sender
{
UIViewController *viewController = [ViewController buildDatePickerViewController];
self.ios7Popover = [[UIPopoverController alloc]initWithContentViewController:viewController];
self.ios7Popover.delegate = self;
[self.ios7Popover presentPopoverFromRect:sender.frame
inView:self.view
permittedArrowDirections:(UIPopoverArrowDirectionUp|UIPopoverArrowDirectionDown| UIPopoverArrowDirectionLeft|UIPopoverArrowDirectionRight)
animated:YES];
}
// popup date picker using UIPopoverPresentationController (IOS8 or later required)
// Thanks to http://stackoverflow.com/a/26944036/1764243 for how to do this
- (IBAction)datePickerPopupIOS8:(UIButton *)sender
{
if ([UIPopoverPresentationController class])
{
UIViewController *viewController = [ViewController buildDatePickerViewController];
UINavigationController *destNav = [[UINavigationController alloc] initWithRootViewController:viewController];
destNav.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *popover = destNav.popoverPresentationController;
popover.delegate = self;
popover.sourceView = self.view;
popover.sourceRect = [sender frame];
destNav.navigationBarHidden = YES;
[self presentViewController:destNav animated:YES completion:nil];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Not supported"
message:#"UIPopoverPresentationController not supported in this version of IOS"
delegate:nil
cancelButtonTitle:#"Ok"
otherButtonTitles:nil];
[alert show];
}
}
#pragma mark - UIPopoverControllerDelegate methods
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{
self.ios7Popover = nil;
}
#end

Add UIScrollView with Paging to Existing UIViewController

I'm wanting to add a UIScrollView with paging to go through different views from my existing view controller which is the root view of my app. I also have tab bar and navigation bar controllers along with it. Can I add a scroll view to this view controller to accomplish what I'm wanting, and if so, can someone point me in the right direction on how to go about it?
Here is my view controller.
#import "KFBViewController.h"
#import "ListViewController.h"
#import "ActionAlertsViewController.h"
#import "MarketUpdatesViewController.h"
#import "AgStoriesViewController.h"
#import "KFBNewsViewController.h"
#import "MemberBenefits.h"
#import "SocialNetworks.h"
#import "WebViewController.h"
#import "YouTubeView.h"
#import "KFBFlickrViewController.h"
#import "RSFM.h"
#import "UAPush.h"
#import "TUSafariActivity.h"
#interface KFBViewController ()
{
}
#end
#implementation KFBViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
self.title = NSLocalizedString(#"Home", #"Home");
self.tabBarItem.image = [UIImage imageNamed:#"home"];
self.navigationController.delegate = self;
}
return self;
}
- (void) showMenu
{
NSURL *urlToShare = [NSURL URLWithString:#"https://itunes.apple.com/us/app/kentucky-farm-bureau/id580530986?mt=8"];
NSArray *activityItems = #[urlToShare];
// TUSafariActivity *activity = [[TUSafariActivity alloc] init];
UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
activityVC.excludedActivityTypes = #[UIActivityTypePrint, UIActivityTypeAssignToContact, UIActivityTypePostToWeibo, UIActivityTypeSaveToCameraRoll];
[self presentViewController:activityVC animated:TRUE completion:nil];
}
- (IBAction)gotoSecondView
{
YouTubeView *youTubeView = [[YouTubeView alloc] initWithNibName:#"YouTubeView" bundle:nil];
youTubeView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:youTubeView animated:YES completion:nil];
}
- (IBAction)gotoPublicAffairs
{
ListViewController *publicAffairs = [[ListViewController alloc]initWithStyle:UITableViewStylePlain];
WebViewController *wvc = [[WebViewController alloc]init];
[publicAffairs setWebViewController:wvc];
publicAffairs.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.navigationController pushViewController:publicAffairs animated:YES];
}
- (IBAction)gotoActionAlerts
{
ActionAlertsViewController *actionAlerts = [[ActionAlertsViewController alloc]initWithStyle:UITableViewStylePlain];
WebViewController *wvc = [[WebViewController alloc]init];
[actionAlerts setWebViewController:wvc];
actionAlerts.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.navigationController pushViewController:actionAlerts animated:YES];
}
- (IBAction)gotoMarketUpdates
{
MarketUpdatesViewController *marketUpdates = [[MarketUpdatesViewController alloc]initWithStyle:UITableViewStylePlain];
WebViewController *wvc = [[WebViewController alloc]init];
[marketUpdates setWebViewController:wvc];
marketUpdates.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.navigationController pushViewController:marketUpdates animated:YES];
}
- (IBAction)gotoAgStories
{
AgStoriesViewController *agStories = [[AgStoriesViewController alloc]initWithStyle:UITableViewStylePlain];
WebViewController *wvc = [[WebViewController alloc]init];
[agStories setWebViewController:wvc];
agStories.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.navigationController pushViewController:agStories animated:YES];
}
- (IBAction)gotoKFBNews
{
KFBNewsViewController *kfbNews = [[KFBNewsViewController alloc]initWithStyle:UITableViewStylePlain];
WebViewController *wvc = [[WebViewController alloc]init];
[kfbNews setWebViewController:wvc];
kfbNews.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.navigationController pushViewController:kfbNews animated:YES];
}
- (IBAction)gotoMemberBenefits
{
MemberBenefits *memberBenefits = [[MemberBenefits alloc] initWithNibName:nil bundle:nil];
memberBenefits.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.navigationController pushViewController:memberBenefits animated:YES];
}
-(IBAction)gotoPhotos:(id)sender
{
KFBFlickrViewController *photosView = [[KFBFlickrViewController alloc] initWithNibName:#"KFBFlickrViewController" bundle:nil];
[self.navigationController pushViewController:photosView animated:YES];
}
- (IBAction)gotoSocialNetworks
{
SocialNetworks *socialNetworks = [[SocialNetworks alloc] initWithNibName:nil bundle:nil];
socialNetworks.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.navigationController pushViewController:socialNetworks animated:YES];
}
- (IBAction)gotoFarmMarkets
{
RSFM *rsfm = [[RSFM alloc] initWithNibName:nil bundle:nil];
rsfm.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.navigationController pushViewController:rsfm animated:YES];
}
- (IBAction)settingsButtonPressed:(id)sender
{
[UAPush openApnsSettings:self animated:YES];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.title = #"Home";
UIBarButtonItem *settingsButton = [[UIBarButtonItem alloc] initWithTitle:#"\u2699" style:UIBarButtonItemStyleBordered target:self action:#selector(settingsButtonPressed:)];
[settingsButton setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont boldSystemFontOfSize:24], UITextAttributeFont,nil] forState:UIControlStateNormal];
self.navigationItem.leftBarButtonItem = settingsButton;
UIBarButtonItem *systemAction = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:#selector(showMenu)];
self.navigationItem.rightBarButtonItem = systemAction;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
#end
This works really well for me:
Declare a property for your UIScrollView, and set your ViewController as a UIScrollViewDelegate
#interface ViewController : UIViewController<UIScrollViewDelegate>
#property (strong, nonatomic) UIScrollView *theScrollView;
#end
**Note that I'm setting up my UIScrollView with code, but it can easily be done with a XIB.
In viewDidLoad: of your ViewController
self.theScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 50, self.view.frame.size.width, 300)];
self.theScrollView.delegate = self;
self.theScrollView.pagingEnabled = YES;
self.theScrollView.showsHorizontalScrollIndicator = NO;
self.theScrollView.showsVerticalScrollIndicator = NO;
[self.view addSubview:self.theScrollView];
NSArray *viewArray = [NSArray arrayWithObjects://your UIViews];
for(int i=0; i<viewArray.count; i++)
{
CGRect frame;
frame.origin.x = self.theScrollView.frame.size.width * i;
frame.origin.y = 0;
frame.size = self.theScrollView.frame.size;
UIView *subview = [[UIView alloc] initWithFrame:frame];
[subview addSubview:[viewArray objectAtIndex:i]];
[self.theScrollView addSubview:subview];
}
self.theScrollView.contentSize = CGSizeMake(self.theScrollView.frame.size.width * viewArray.count, self.theScrollView.frame.size.height);
Most paging scrollViews also have a UIPageControl associated with it. To do that, override this UIScrollViewDelegate method:
- (void)scrollViewDidScroll:(UIScrollView *)sender {
CGFloat pageWidth = self.theScrollView.frame.size.width;
int page = floor((self.theScrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
self.thePageControl.currentPage = page;
}
I would perhaps try using UIPageViewController, rather than a regular paging scrollview.
Apple's PhotoScroller sample code provides a very good example of how to use UIPageViewController.
I also have some code on github that modifies PhotoScroller to load the UIPageViewController inside a UIViewController subclass. (In Apple's sample code, the UIPageViewController is the root view controller.)
I have never used a UIPageViewController with different UIViewController subclasses in each page (the PhotoScroller sample code uses PhotoViewControllers in all pages), but I can't see why it couldn't be done with a few modifications to the code.
This link helps for you. Here page controller and scrollview both are used -
PageControl Example in iPhone

PopupViewController returns null to ViewController

I would like to pass datepicker.date from DatePickerPopupViewController to my SensorvViewcontroller which is shown below. However, it returns me "null". What am I doing wrong? My code is as follows:
#import "DatePopoverViewController.h"
#interface DatePopoverViewController ()
#end
#implementation DatePopoverViewController
#synthesize datePicker;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
datePicker.date=[NSDate date];
}
#end
#import "SensorViewController.h"
#interface SensorViewController ()
#end
// this represent my button which triggers popupViewController
-(void)chooseDate
{
if([popoverController isPopoverVisible])
{
[popoverController dismissPopoverAnimated:YES];
}
else
{
CGRect popRect=CGRectMake (900,1,1,1);
//CGRect popRect=CGRectMake (tools.frame.origin.x,tools.frame.origin.y,50,50);
popoverController.popoverContentSize =CGSizeMake(320,216);
[popoverController presentPopoverFromRect:popRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
datepop=[[DatePopoverViewController alloc]init];
NSDate *ali= datepop.datePicker.date;
NSLog(#"%#",ali);
}
}
#end
This code:
CGRect popRect=CGRectMake (900,1,1,1);
//CGRect popRect=CGRectMake (tools.frame.origin.x,tools.frame.origin.y,50,50);
popoverController.popoverContentSize =CGSizeMake(320,216);
[popoverController presentPopoverFromRect:popRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
datepop=[[DatePopoverViewController alloc]init];
NSDate *ali= datepop.datePicker.date;
NSLog(#"%#",ali);
Should probably be more like:
popoverController=[[DatePopoverViewController alloc]init];
CGRect popRect=CGRectMake (900,1,1,1);
//CGRect popRect=CGRectMake (tools.frame.origin.x,tools.frame.origin.y,50,50);
popoverController.popoverContentSize =CGSizeMake(320,216);
[popoverController presentPopoverFromRect:popRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
And you should setup a delegate relationship or a block callback so that when the user has actually selected a date a method is called and you can do:
NSDate *ali= popoverController.datePicker.date;
NSLog(#"%#",ali);
Or, better, the popover controller gets the date from the picker and passes it as a parameter to the callback method / block.
Something like (typed inline):
In the popover:
typedef void (^CompletionBlock) ();
#propertty (copy, nonatomic) CompletionBlock completionBlock;
- (void)dateSelected {
self.completion();
}
In the source controller:
self.popoverController.completionBlock = ^{
NSLog(#"%#", self.popoverController.datePicker.date);
};
This following code works:
//in header
#property (nonatomic,strong) UIDatePicker *datePicker;
//in implementation
UIViewController* popoverContent = [[UIViewController alloc] init]; //ViewController
UIView *popoverView = [[UIView alloc] init]; //view
popoverView.backgroundColor = [UIColor blackColor];
datePicker=[[UIDatePicker alloc]init];//Date picker
datePicker.frame=CGRectMake(0,44,320, 216);
datePicker.datePickerMode = UIDatePickerModeDateAndTime;
[datePicker setMinuteInterval:5];
[datePicker setTag:10];
[datePicker addTarget:self action:#selector(Result) forControlEvents:UIControlEventValueChanged];
[popoverView addSubview:datePicker];
popoverContent.view = popoverView;
popoverController = [[UIPopoverController alloc] initWithContentViewController:popoverContent];
popoverController.delegate=self;
[popoverContent release];
[popoverController setPopoverContentSize:CGSizeMake(320, 264) animated:NO];
[popoverController presentPopoverFromRect:tempButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];//tempButton.frame where you need you can put that frame
-(void)Result
{
NSLog (#"Pciked Date%#", datePicker.date);
}

UIPopoverController for iPad "must not be called with `nil`" error

I am trying to make an iPhone app work in an iPad but the UIPopoverController is
comming back with error.
- (IBAction)photoTapped1 {
if(UI_USER_INTERFACE_IDIOM()== UIUserInterfaceIdiomPhone){
// If in editing state, then display an image picker; if not, create and push a photo view controller.
if (self.editing) {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
[self presentViewController:imagePicker animated:YES completion:nil];
[imagePicker release];
} else {
RecipePhotoViewController *recipePhotoViewController = [[RecipePhotoViewController alloc] init];
recipePhotoViewController.hidesBottomBarWhenPushed = YES;
recipePhotoViewController.recipe = recipe;
[self.navigationController pushViewController:recipePhotoViewController animated:YES];
[recipePhotoViewController release];
}
}else{
if (self.editing){
self.popover = [[UIPopoverController alloc] initWithContentViewController:popover];
self.popover.delegate =self;
[popover release];
}else{
RecipePhotoViewController *recipePhotoViewController = [[RecipePhotoViewController alloc] init];
recipePhotoViewController.hidesBottomBarWhenPushed = YES;
recipePhotoViewController.recipe = recipe;
[self.navigationController pushViewController:recipePhotoViewController animated:YES];
[recipePhotoViewController release];
}}}
The error I am getting is:
'NSInvalidArgumentException', reason: '-[UIPopoverController initWithContentViewController:] must not be called with nil.'
Anyone available to give me a hand on this code, I have looked on the internet for solutions and samples but can not seem to make it work.
Thank you.
___ added to original question_____
I am adding the recipePhotoViewController here, I am assuming that ImageView manipulation is the same for iPhone and iPad.
my.h File
#class Recipe;
#interface RecipePhotoViewController : UIViewController {
#private
Recipe *recipe;
UIImageView *imageView;
}
#property(nonatomic, retain) Recipe *recipe;
#property(nonatomic, retain) UIImageView *imageView;
#end
Here is my .m file
#implementation RecipePhotoViewController
#synthesize recipe;
#synthesize imageView;
- (void)loadView {
self.title = #"Photo";
imageView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
imageView.contentMode = UIViewContentModeScaleAspectFit;
imageView.backgroundColor = [UIColor blackColor];
self.view = imageView; }
- (void)viewWillAppear:(BOOL)animated {
imageView.image = [recipe.image valueForKey:#"image"];}
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
- (void)dealloc {
[imageView release];
[recipe release];
[super dealloc];
} #end
You are initializing the popover controller in a wrong way:
self.popover = [[UIPopoverController alloc] initWithContentViewController:popover];
You should pass the controller you would like to display inside of the popover -- not the popover itself (which is nil since you have not yet initialised it)!
Maybe this would do it for you?
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
self.popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
If this is correct, then you should also present the pop over you have just created: – presentPopoverFromRect:inView:permittedArrowDirections:animated:
-- e.g.:
[self.popover presentPopoverFromRect:sender.frame inView:[self view] permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
where sender is the argument to :
- (IBAction)photoTapped1:(id)sender {
The content of your popover which you store in the variable popover is obviously nil. I can't see it ever being created in the code you provided.
Maybe you intended to present the Recipe photo controller as the content of the popover. In that case you would do something like
RecipePhotoViewController *recipePhotoViewController = [[RecipePhotoViewController alloc] init];
self.popover = [[UIPopoverController alloc] initWithContentViewController:recipePhotoViewController];
problem is in this line of your code ,
self.popover = [[UIPopoverController alloc] initWithContentViewController:popover];
try like this
UIViewController* popoverContent = [[UIViewController alloc] init];
UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 400, 320, 260)];
popoverContent.view = popoverView;
//Add what ever you want popoverView
self.popover = [[UIPopoverController alloc] initWithContentViewController:popoverContent];
self.popover.delegate =self;

Resources