Monday, 16 March 2015

Use iOS 8 default blur view

// -- add blur effect
    UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
    
    UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
    
    [blurEffectView setFrame:self.view.bounds];
    
    
    [self.view addSubview:blurEffectView];

    //[self.view insertSubview:blurEffectView atIndex:0];

Thursday, 12 March 2015

UIImagePickerController has iPad issue in iOS 8 : Attempt to present on which is already presenting (null)


I think this is because in iOS 8, alert views and action sheets are actually presented view controllers (UIAlertController). So, if you're presenting a new view controller in response to an action from the UIAlertView, it's being presented while the UIAlertController is being dismissed. I worked around this by delaying the presentation of the UIImagePickerController until the next iteration of the runloop, by doing this:

[[NSOperationQueue mainQueue] addOperationWithBlock:^{
    // just add picker code here and it will work fine.
}];

Image Popup in popover view : small popup in UIView

- (IBAction)btnShowImage:(UIButton*)sender
{
//    Declare below declaration in .h file
//    UIPopoverController  *popoverVC;
    
    
    if([popoverVC isPopoverVisible])
    {
        //close the popover view if toolbar button was touched
        //again and popover is already visible
        //Thanks to @chrisonhismac
        
        [popoverVC dismissPopoverAnimated:YES];
        return;
    }
    
    //build our custom popover view
    UIViewController* popoverContent = [[UIViewController alloc] init];
    
    UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 250, 250)];
    
    popoverView.backgroundColor = [UIColor whiteColor];
    
    popoverContent.view = popoverView;
    
    
    
    ////-- show image in popover view
    GPImageView *imgView = [[GPImageView alloc] initWithFrame:CGRectMake(10, 10, 230, 230)];
    
    NSString *imgURL = [SiteAPIURL stringByAppendingFormat:@"resizeImage.php?width=460&height=460&imagename=%@", dictCustomer[@"photo"]];
    
    [imgView setImageFromURL:imgURL
       showActivityIndicator:YES
               setCacheImage:YES];
    
    [popoverView addSubview:imgView];
    
    
    
    //create a popover controller
    popoverVC = [[UIPopoverController alloc] initWithContentViewController:popoverContent];
    
    popoverVC.contentViewController.preferredContentSize =  CGSizeMake(250, 250);
    
    [popoverVC presentPopoverFromRect:sender.frame   // did you forget to call this method?
                               inView:self.view
             permittedArrowDirections:UIPopoverArrowDirectionLeft
                             animated:YES];
}

Tuesday, 3 March 2015

SNV terminal command MacOSX Subversion-Client-1.8.11_10.10.x

SVN
export PATH=/opt/subversion/bin:$PATH

//check out to pwd (.)
svn --username test --password 123 co https://192.168.1.40/svn/android

//push android/ to server
svn import -m "New Import"  android/ https://test@192.168.1.40/svn/android
--------------------------------------------------------------------------------------------

Make another build SDK (like iOS 6.1 add to XCode 5 where iOS7 sdk already available) in exsiting XCode SDK

Macintosh HD ▸ Applications ▸ Xcode5.app ▸ Contents ▸ Developer ▸ Platforms
STEP 1 : OPEN FINDER
STEP 2 : PRESS
CMD+SHIFT+g  
STEP 3 : PASTE BELOW LINE
/Applications/Xcode.app/Contents/Developer/Platforms
STEP 4: PASTE THE COPIED FIELES ON THAT FOLDER

Monday, 2 March 2015

get all files in nested directory in iOS Objective C

NSArray *arrayFilesPath = [self openEachFileAt:DOCUMENT_PATH];
NSLog(@"All path %@", arrayFilesPath);
- (NSMutableArray*)openEachFileAt:(NSString*)path {
    NSString* file;
    
    NSMutableArray *arrayFilePath = [NSMutableArray new];
    
    NSDirectoryEnumerator* enumerator = [[NSFileManager defaultManager] enumeratorAtPath:path];
    
    while (file = [enumerator nextObject])
    {
        // check if it's a directory
        BOOL isDirectory = NO;
        
        [[NSFileManager defaultManager] fileExistsAtPath: [NSString stringWithFormat:@"%@/%@",path,file]
                                             isDirectory: &isDirectory];
        if (!isDirectory)
        {
            // open your file …
            [arrayFilePath addObject:[NSString stringWithFormat:@"%@/%@",path,file]];
        }
        else
        {
            [arrayFilePath addObjectsFromArray:[self openEachFileAt: file]];
        }
    }
    
    return arrayFilePath;
}

Sunday, 1 March 2015

rename files in folder using python script

import os
# a~ipad.png to a.png
[os.rename(f, f.replace('~ipad', '')) for f in os.listdir('.') if not f.startswith('.')]