Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.17 KB | None | 0 0
  1. [myPopover presentPopoverFromRect:cell.frame inView:self.tableView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
  2.  
  3. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  4.  
  5. UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
  6. CGRect rect=CGRectMake(cell.bounds.origin.x+600, cell.bounds.origin.y+10, 50, 30);
  7. [popOverController presentPopoverFromRect:rect inView:cell permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
  8.  
  9. }
  10.  
  11. CGRect aFrame = [self.myDetailViewController.tableView rectForRowAtIndexPath:[NSIndexPath indexPathForRow:theRow inSection:1]];
  12. [popoverController presentPopoverFromRect:[self.myDetailViewController.tableView convertRect:aFrame toView:self.view] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
  13.  
  14. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  15. {
  16. UIView *aView = [[UIView alloc] init];
  17. // initialize view here
  18.  
  19. UIPopoverController *popoverController = [[UIPopoverController alloc]
  20. initWithContentViewController:aView];
  21. popoverController.popoverContentSize = CGSizeMake(320, 416);
  22. UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
  23. [popoverController presentPopoverFromRect:cell.bounds inView:cell.contentView
  24. permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
  25.  
  26. [aView release];
  27. // release popover in 'popoverControllerDidDismissPopover:' method
  28. }
  29.  
  30. CGRect rect = [aTableView rectForRowAtIndexPath:indexPath];
  31.  
  32. //create a 10 pixel width rect at the center of the cell
  33.  
  34. rect.origin.x = (rect.size.width - 10.0) / 2.0;
  35. rect.size.width = 10.0;
  36.  
  37. [self.addExpensePopoverController presentPopoverFromRect:rect inView:aTableView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
  38.  
  39. UIView *accessoryView = cell.accessoryView; // finds custom accesoryView (cell.accesoryView)
  40. if (accessoryView == nil) {
  41. UIView *cellContentView = nil;
  42.  
  43. for (UIView *accView in [cell subviews]) {
  44. if ([accView isKindOfClass:[UIButton class]]) {
  45. accessoryView = accView; // find generated accesoryView (UIButton)
  46. break;
  47. } else if ([accView isKindOfClass:NSClassFromString(@"UITableViewCellContentView")]) {
  48. // find generated UITableViewCellContentView
  49. cellContentView = accView;
  50. }
  51. }
  52. // if the UIButton doesn't exists, find cell contet view (UITableViewCellContentView)
  53. if (accessoryView == nil) {
  54. accessoryView = cellContentView;
  55. }
  56. // if the cell contet view doesn't exists, use cell view
  57. if (accessoryView == nil) {
  58. accessoryView = cell;
  59. }
  60. }
  61.  
  62. [actionSheet showFromRect:accessoryView.bounds inView:accessoryView animated:YES];
  63.  
  64. -(UIView*)getViewForSheetAndPopUp:(UITableViewCell*)cell;
  65.  
  66. -(UIView*)getViewForSheetAndPopUp:(UITableViewCell*)cell {
  67. UIView *accessoryView = cell.accessoryView;
  68.  
  69. if (accessoryView == nil) {
  70. UIView *cellContentView = nil;
  71.  
  72. for (UIView *accView in [cell subviews]) {
  73. if ([accView isKindOfClass:[UIButton class]]) {
  74. accessoryView = accView;
  75. break;
  76. } else if ([accView isKindOfClass:NSClassFromString(@"UITableViewCellContentView")]) {
  77. cellContentView = accView;
  78. }
  79. }
  80.  
  81. if (accessoryView == nil) {
  82. accessoryView = cellContentView;
  83. }
  84. if (accessoryView == nil) {
  85. accessoryView = cell;
  86. }
  87. }
  88.  
  89. return accessoryView;
  90. }
  91.  
  92. -(IBAction)displaySomeCellRelativePopover:(id)sender{
  93. //passes the actions to its delegate
  94. UIButton *button = (UIButton *)sender;
  95. [cellActionDelegate displaySomeCellRelativePopoverWithInformation:self.info
  96. fromButton:button
  97. fromCell:self];
  98. }
  99.  
  100. -(void)displaySomeCellRelativePopoverWithInformation:(MyCellInformationClass *)info
  101. fromButton:(UIButton *)button
  102. fromCell:(UIView *)cell{
  103.  
  104. UIPopoverController * popoverController = nil;
  105.  
  106. //create your own UIPopoverController the way you want
  107.  
  108. //Convert your button/view frame
  109.  
  110. CGRect buttonFrameInDetailView = [self.view convertRect:button.frame fromView:cell];
  111.  
  112. //present the popoverController
  113. [popoverController presentPopoverFromRect:buttonFrameInDetailView
  114. inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];]
  115.  
  116.  
  117. //release objects created...
  118. }
  119.  
  120. RidersVC *vc = [RidersVC ridersVC];
  121. vc.modalPresentationStyle = UIModalPresentationPopover;
  122. vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
  123. UIPopoverPresentationController *popPresenter = [vc popoverPresentationController];
  124. popPresenter.sourceView = vc.view;
  125. popPresenter.barButtonItem= [[UIBarButtonItem alloc] initWithCustomView:button];
  126. popPresenter.backgroundColor = [UIColor colorWithRed:220.0f/255.0f green:227.0f/255.0f blue:237.0f/255.0f alpha:1.0];
  127. [self.parentVC presentViewController:vc animated:YES completion:NULL];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement