uitabelview in uipopoverview - iphone

Can any one please give me reference or tutorial for how to include uitabelview in uipopopover view Controlelr with detail view controller,Please do the needfully, Thanks in advance
Update:
- (IBAction) useCameraRoll: (id)sender
{
if([self.popoverController isPopoverVisible])
{
[self.popoverController dismissPopoverAnimated:YES];
return;
}
//build our custom popover view
UIViewController* popoverContent = [[UIViewController alloc]init];
UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 140, 102)];
popoverView.backgroundColor = [UIColor blackColor];
UITableView *tblViewMenu = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 140, 102)];
tblViewMenu.delegate = self;
tblViewMenu.dataSource = self;
tblViewMenu.rowHeight = 32;
[popoverView addSubview:tblViewMenu];
popoverContent.view = popoverView;
popoverContent.contentSizeForViewInPopover = CGSizeMake(140, 102);
self.popoverController = [[UIPopoverController alloc]
initWithContentViewController:popoverContent];
//present the popover view non-modal with a
//refrence to the toolbar button which was pressed
[self.popoverController presentPopoverFromRect:CGRectMake(0, 0, 133, 29)
inView:gal permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}

Please try to google your Query before posting here.
You can find one tutorial here
http://iphoneapp-dev.blogspot.in/2010/11/how-to-insert-uitableview-in.html

Related

UIPopoverController is showing on the other button

When UIButton is tapped to display UIPopovercontroller, it is showing on the other UIbarbuttonitemand it is showing blank black opaque UIPopovercontroller.
Here is my implemented code:
- (IBAction)buttonTapped:(id)sender {
UIButton *btnAction;
BookmarkViewController* bookmarkVC = [[BookmarkViewController alloc] init];
_buttonPopoverController = [[UIPopoverController alloc]
initWithContentViewController:bookmarkVC];
_buttonPopoverController.delegate = self;
CGRect popoverFrame = btnAction.frame;
[_buttonPopoverController setPopoverContentSize:CGSizeMake(320, 355) animated:NO];
//only required if using delegate methods
[_buttonPopoverController presentPopoverFromRect:popoverFrame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];
}
UIButton *btnAction=(UIButton*) sender;
You are missing to assing sender to btnAction
that is UIButton *btnAction=(UIButton *)sender;
try this,
- (IBAction)buttonTapped:(id)sender {
UIButton *btnAction=(UIButton *)sender;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
UIViewController *bookmarkVC = [storyboard instantiateViewControllerWithIdentifier:#"BookmarkViewController"];
_buttonPopoverController = [[UIPopoverController alloc]
initWithContentViewController:bookmarkVC];
_buttonPopoverController.delegate = self;
CGRect popoverFrame = btnAction.frame;
[bookmarkVC setContentSizeForViewInPopover:CGSizeMake(320, 355)];
//only required if using delegate methods
[_buttonPopoverController presentPopoverFromRect:popoverFrame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];
}
Your issue is here
[_buttonPopoverController presentPopoverFromRect:popoverFrame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];
where presentPopoverFromRect:popoverFrame should be actually the rect of the popover not of the UIButton and also the btnAction has no frame you haven't allocated it also and you are performing CGRect popoverFrame = btnAction.frame;
It should be like
[popover presentPopoverFromRect:CGRectMake(0.0, 0.0, 300.0, 50.0) inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
Hope this helps.

Why is UIPopoverController so tall?

I have the following code to open a 320px x 320px UIPopoverController, but for some reason the popover is much taller than it should be - about twice the height that I specified (320px).
What's gone wrong?
colorPicker = [[RSColorPickerView alloc] initWithFrame:CGRectMake(20.0, 20.0, 320.0, 320.0)];
[colorPicker setDelegate:self];
[colorPicker setBrightness:1.0];
[colorPicker setCropToCircle:YES];
[colorPicker setBrightness:1.0];
[colorPicker setBackgroundColor:[UIColor clearColor]];
UIColor * aColor = [UIColor colorWithRed:0.803 green:0.4 blue:0.144 alpha:1];
[colorPicker setSelectionColor:aColor];
UIView *newview = [[UIView alloc] initWithFrame:CGRectMake(20.0, 20.0, 320.0, 320.0)];
[newview addSubview:colorPicker];
UIViewController *newviewcontroller = [[UIViewController alloc] init];
[newviewcontroller setView:newview];
UIPopoverController *newpopover =
[[UIPopoverController alloc] initWithContentViewController:newviewcontroller];
newpopover.delegate = self;
[self.colourController setPopoverContentSize:CGSizeMake(320, 320)];
self.colourController = newpopover;
[self.colourController presentPopoverFromRect:CGRectMake(149, 540, 1, 1) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
You need to set the popoverContentSize on the view controller being presented in the popover. You are setting it on the wrong view controller.
newpopover.delegate = self;
self.colourController = newpopover;
[self.colourController setPopoverContentSize:CGSizeMake(320, 320)];
You were doing these last two lines out of order.

UIPopover crashing from UIButton

I'm presenting a UIPopover from a UIButton but my app is crashing at line [popoverController presentPopoverFromRect:[button bounds] inView:button permittedArrowDirections:UIPopoverArrowDirectionRight animated:NO];
- (IBAction)birthdayButtonClicked:(id)sender
{
UIViewController* popoverContent = [[UIViewController alloc] init];
UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 344)];
popoverView.backgroundColor = [UIColor whiteColor];
UIDatePicker *datePicker = [[UIDatePicker alloc]init];
datePicker.frame = CGRectMake(0, 44, 320, 300);
[popoverView addSubview:self.view];
[popoverView addSubview:datePicker];
popoverContent.view = popoverView;
popoverContent.contentSizeForViewInPopover = CGSizeMake(320, 244);
UIPopoverController *popoverController = [[UIPopoverController alloc] initWithContentViewController:popoverContent];
UIButton *button = (UIButton *)sender;
[popoverController presentPopoverFromRect:[button bounds] inView:button permittedArrowDirections:UIPopoverArrowDirectionRight animated:NO];
[popoverView release];
[popoverContent release];
}
It is not a good idea to add self.view as subview. UIView object can be displayed only once in every current mooment, you cannot show popover with content as self.view in self.view. If you really need to perform this task then try to make copy of required views.
Change the inView to self.view. inView means in which UIView you want to present popover.
presentPopoverFromRect:[button bounds] inView:**self.view** permittedArrowDirections:UIPopoverArrowDirectionRight animated:NO];

UIDatePicker in UIActionSheet on iPad

In the iPhone version of my app, I have a UIDatePicker in a UIActionSheet. It appears correctly. I am now setting up the iPad version of the app, and the same UIActionSheet when viewed on the iPad appears as a blank blank box.
Here is the code I am using:
UIDatePicker *datePickerView = [[UIDatePicker alloc] init];
datePickerView.datePickerMode = UIDatePickerModeDate;
self.dateActionSheet = [[UIActionSheet alloc] initWithTitle:#"Choose a Follow-up Date"
delegate:self cancelButtonTitle:nil
destructiveButtonTitle:nil otherButtonTitles:#"Done", nil];
[self.dateActionSheet showInView:self.view];
[self.dateActionSheet addSubview:datePickerView];
[self.dateActionSheet sendSubviewToBack:datePickerView];
[self.dateActionSheet setBounds:CGRectMake(0,0,320, 500)];
CGRect pickerRect = datePickerView.bounds;
pickerRect.origin.y = -95;
datePickerView.bounds = pickerRect;
I ended up creating a separate segment of code for the iPad Popover:
//build our custom popover view
UIViewController* popoverContent = [[UIViewController alloc] init];
UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 344)];
popoverView.backgroundColor = [UIColor whiteColor];
datePicker.frame = CGRectMake(0, 44, 320, 300);
[popoverView addSubview:toolbar];
[popoverView addSubview:datePicker];
popoverContent.view = popoverView;
//resize the popover view shown
//in the current view to the view's size
popoverContent.contentSizeForViewInPopover = CGSizeMake(320, 244);
//create a popover controller
UIPopoverController *popoverController = [[UIPopoverController alloc] initWithContentViewController:popoverContent];
//present the popover view non-modal with a
//refrence to the button pressed within the current view
[popoverController presentPopoverFromBarButtonItem:self.navigationItem.leftBarButtonItem
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
//release the popover content
[popoverView release];
[popoverContent release];

Change pop-over contentsize using navigationcontroller

I want to show a popover with a custom contentsize.
I can do it doing like so
UINavigationController* popoverContent = [[UINavigationController alloc] init];
UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 800, 800)];
popoverView.backgroundColor = [UIColor blueColor];
popoverContent.view = popoverView;
popoverContent.contentSizeForViewInPopover = CGSizeMake(55, 55);
UIPopoverController *pop = [[UIPopoverController alloc] initWithContentViewController:popoverContent];
[pop presentPopoverFromRect:CGRectMake(80.0, 210.0, 160.0, 40.0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
but if I change the content to :
popoverContent.viewControllers = [NSArray arrayWithObject:myViewController];
the
popoverContent.contentSizeForViewInPopover = CGSizeMake(55, 55);
the size doesn't change at all.
How can I change the content size while using the navigation controller?
Thanks
Explicitly changing the popovers size works:
[self.popoverController setPopoverContentSize:myView.size animated:YES];
But I agree that contentSizeForViewInPopover should work. It doesn't for me anyway.