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 :)

Tuesday, March 26, 2013

GMGridview long press delete and moving cell at same time

GMGridview is very essential library project for cell manipulation for iOS project which are moving cell and delete cell and etc.But I have seen there was a problem you can't add two animation with same time like when moving and delete animation with same time.

So i have changed it as i want ,


Problem is : long-press delete and moving cell same time.

Solution is : when you are long pressing,it active the delete mode then if you want delete cell ,you can delete  it , if you want to moving cell you can move cell but while moving delete mode is deactivate and after releasing cell delete mode also active again.

So i have create sub class of GMGridview and change the rules what you want.But some methods and variables are private So you should move in to GMGridview.h file .

Step 1  : Add properties to GMGridview header file 



And syntheses the this properties and remove private variable these name in GMGridview.h file.

 Step 2  : Add methods to GMGridview header file 

Step 3    : create sub class of GMGridview and changed rules as follow(GMGridViewSub)
Step 3.1 : Header file

















Step 3.2 : Implementation file(m)
Step 3.2.1 : Import header file and constant as follow 

















Step 3.2.2 : Add following init and function within implementation scope as follow

It first call super class function and then run remainder task.Change the valid rule as following code because it check without editing.


Longpress GestureUpdate : Add the moving editing animation as follow and
SortingMoveDidStart :  before start the moving edit mode is NO 





























Change following function Edditing is yes and after stop the animation changed it as

if(self.editing)
     self.sortMovingItem.editing =YES;
















While moving cell editing flag is NO








Now you have developed the sub class of GMGridView and then you can call the subclass as you want instead of GMGridView Add this reference as you wanted class as follow.

GMGridViewSub *gmGridView = [[GMGridViewSub alloc] init];