Friday, May 31, 2013

Load ios print popover inside the our popover

I had a problem which is ,after opening the file there is a share button and when click the share button popover will be appeared. In this popover there are two button one of the button is print.

Problem is after clicking the print button print popover is showing the different popover reason is print popover is generated by ios only thing we need to input the some parameter which are file path of the print file,etc and print controller is not a UIviewcontroller so it cannot push to the navigation controller.

So iOs gave us to a delegate method it return the which navigation controller is needed to push.

Method is

 #pragma -mark UIPrintInteractionControllerDelegate

- (UIViewController *)printInteractionControllerParentViewController:(UIPrintInteractionController *)printInteractionController
{
return self.firstPopoverController.navigationController;
}

if you override the method you can load your print popover given navigation controller.

Tuesday, May 28, 2013

Identify single tap and double tap in ios

I had faced this kind of issue with gestures which is I have used custom gesture for single tap and double tap gesture is inbuilt but double tap gesture is not visible to others you cannot access this gesture when creating the single tap gesture.
The issue is when i double tap on the page this app get it as this is two single tap So it is running single tap task.

I used following scenario for solving this issue.

1. Create single tap gesture like this

tapGestureRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(toggleBars)];tapGestureRecognizer.numberOfTouchesRequired = 1;[self.view addGestureRecognizer:tapGestureRecognizer];tapGestureRecognizer.delegate = self;

2.create target function like this

- (void)toggleBars
{
   [self performSelector:@selector(performToggleBars) 
              withObject:nil 
              afterDelay:0.4];
}

- (void)performToggleBars
{
   //task you need to process.
}

3. There is UIGestureRecognizerDelegate delegate method you need to override like this

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
       shouldReceiveTouch:(UITouch *)touch
{
  if (touch.tapCount != 1)
  {
    [NSObject cancelPreviousPerformRequestsWithTarget:self
                                            selector:@selector(performToggleBars)
                                              object:nil];
  }

  return YES;
}

in this scenario cancel the single tap gesture event if it is multiple taps.

Wednesday, May 22, 2013

Solution for popover resizing issue

If you have two controller which are A and B ,open with UIpopover but size is different and which are loaded to navigation stack as first load A controller and then load B controller but B controller size is greater than A controller.When you pushing controllers to navigation stack the issue is not happen.But after coming back through the navigation controller(pop the controllers in stack) popover size is not changed.its size is taken last pushed controller size(B). This issue is ios because popover is not taken current controller size.

So solution is use A controller viewDidAppear function and forcefully changed the size and then again rechange then your issue is solved.

Example :


- (void)forcePopoverResize
{
    CGSize currentSetSizeForPopover = self.contentSizeForViewInPopover;
    CGSize tempPopoverSize = CGSizeMake(currentSetSizeForPopover.width - 1.0f, currentSetSizeForPopover.height - 1.0f);
    self.contentSizeForViewInPopover = tempPopoverSize;
    self.contentSizeForViewInPopover = currentSetSizeForPopover;
}

You can call this function inside the viewDidAppear

[self  forcePopoverResize];

Now your problem is solved :)