Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [myPopover presentPopoverFromRect:cell.frame inView:self.tableView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
- CGRect rect=CGRectMake(cell.bounds.origin.x+600, cell.bounds.origin.y+10, 50, 30);
- [popOverController presentPopoverFromRect:rect inView:cell permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
- }
- CGRect aFrame = [self.myDetailViewController.tableView rectForRowAtIndexPath:[NSIndexPath indexPathForRow:theRow inSection:1]];
- [popoverController presentPopoverFromRect:[self.myDetailViewController.tableView convertRect:aFrame toView:self.view] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- UIView *aView = [[UIView alloc] init];
- // initialize view here
- UIPopoverController *popoverController = [[UIPopoverController alloc]
- initWithContentViewController:aView];
- popoverController.popoverContentSize = CGSizeMake(320, 416);
- UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
- [popoverController presentPopoverFromRect:cell.bounds inView:cell.contentView
- permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
- [aView release];
- // release popover in 'popoverControllerDidDismissPopover:' method
- }
- CGRect rect = [aTableView rectForRowAtIndexPath:indexPath];
- //create a 10 pixel width rect at the center of the cell
- rect.origin.x = (rect.size.width - 10.0) / 2.0;
- rect.size.width = 10.0;
- [self.addExpensePopoverController presentPopoverFromRect:rect inView:aTableView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
- UIView *accessoryView = cell.accessoryView; // finds custom accesoryView (cell.accesoryView)
- if (accessoryView == nil) {
- UIView *cellContentView = nil;
- for (UIView *accView in [cell subviews]) {
- if ([accView isKindOfClass:[UIButton class]]) {
- accessoryView = accView; // find generated accesoryView (UIButton)
- break;
- } else if ([accView isKindOfClass:NSClassFromString(@"UITableViewCellContentView")]) {
- // find generated UITableViewCellContentView
- cellContentView = accView;
- }
- }
- // if the UIButton doesn't exists, find cell contet view (UITableViewCellContentView)
- if (accessoryView == nil) {
- accessoryView = cellContentView;
- }
- // if the cell contet view doesn't exists, use cell view
- if (accessoryView == nil) {
- accessoryView = cell;
- }
- }
- [actionSheet showFromRect:accessoryView.bounds inView:accessoryView animated:YES];
- -(UIView*)getViewForSheetAndPopUp:(UITableViewCell*)cell;
- -(UIView*)getViewForSheetAndPopUp:(UITableViewCell*)cell {
- UIView *accessoryView = cell.accessoryView;
- if (accessoryView == nil) {
- UIView *cellContentView = nil;
- for (UIView *accView in [cell subviews]) {
- if ([accView isKindOfClass:[UIButton class]]) {
- accessoryView = accView;
- break;
- } else if ([accView isKindOfClass:NSClassFromString(@"UITableViewCellContentView")]) {
- cellContentView = accView;
- }
- }
- if (accessoryView == nil) {
- accessoryView = cellContentView;
- }
- if (accessoryView == nil) {
- accessoryView = cell;
- }
- }
- return accessoryView;
- }
- -(IBAction)displaySomeCellRelativePopover:(id)sender{
- //passes the actions to its delegate
- UIButton *button = (UIButton *)sender;
- [cellActionDelegate displaySomeCellRelativePopoverWithInformation:self.info
- fromButton:button
- fromCell:self];
- }
- -(void)displaySomeCellRelativePopoverWithInformation:(MyCellInformationClass *)info
- fromButton:(UIButton *)button
- fromCell:(UIView *)cell{
- UIPopoverController * popoverController = nil;
- //create your own UIPopoverController the way you want
- //Convert your button/view frame
- CGRect buttonFrameInDetailView = [self.view convertRect:button.frame fromView:cell];
- //present the popoverController
- [popoverController presentPopoverFromRect:buttonFrameInDetailView
- inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];]
- //release objects created...
- }
- RidersVC *vc = [RidersVC ridersVC];
- vc.modalPresentationStyle = UIModalPresentationPopover;
- vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
- UIPopoverPresentationController *popPresenter = [vc popoverPresentationController];
- popPresenter.sourceView = vc.view;
- popPresenter.barButtonItem= [[UIBarButtonItem alloc] initWithCustomView:button];
- popPresenter.backgroundColor = [UIColor colorWithRed:220.0f/255.0f green:227.0f/255.0f blue:237.0f/255.0f alpha:1.0];
- [self.parentVC presentViewController:vc animated:YES completion:NULL];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement