Monday, 18 June 2012

urldemo 13

//For get the time zone in standard time + iPhone
-(NSString *)getStandardTimeZone{
    NSTimeZone *timeZone=[NSTimeZone defaultTimeZone];
    NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
    NSString *timeZoneId = [timeZone localizedName:NSTimeZoneNameStyleStandard locale:locale];
    return timeZoneId;
}


//Scroll Tableview to the Bottom in iPhone
 CGRect sectionRect = [self.tableView rectForSection: sectionIndexForNewFolder];
    // Try to get a full-height rect which is centred on the sectionRect
    // This produces a very similar effect to UITableViewScrollPositionMiddle.
    CGFloat extraHeightToAdd = sectionRect.size.height - self.tableView.frame.size.height;
    sectionRect.origin.y -= extraHeightToAdd * 0.5f;
    sectionRect.size.height += extraHeightToAdd;
    [self.tableView scrollRectToVisible:sectionRect animated:YES];


//Viewing hidden files on a Mac
defaults write com.apple.finder AppleShowAllFiles -bool true

//hide  files on a Mac
defaults write com.apple.finder AppleShowAllFiles -bool false

//Randomize the Uiimage color in iPhone
    https://github.com/OmidH/Filtrr

//Random an Array in iPhone
NSInteger randomize(id num1, id num2, void *context)
{
    int rand = arc4random() %2;
    if (rand)
        return NSOrderedAscending;
    else
        return NSOrderedDescending;
}
NSMutableArray *temp=[[NSMutableArray alloc] init];
    for ( int i=0; i<=10; i++) {
        [temp addObject:[NSString stringWithFormat:@"%d",i]];
    }
[temp sortUsingFunction:randomize context:NULL];
NSLog(@"%@",temp);




 //Swipe a view like off some and push or pop in iPhone with pan gesture.

    UIPanGestureRecognizer *panGesture = nil;
    panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panViewWithGestureRecognizer:)];
   
    [panGesture setMaximumNumberOfTouches:2];
    [panGesture setDelegate:self];
   
    [adminView addGestureRecognizer:panGesture];
    [panGesture release];
- (void)panViewWithGestureRecognizer:(UIPanGestureRecognizer *)gestureRecognizer
{   
   
    CGPoint velocity = [gestureRecognizer velocityInView:adminView];
   
    if(velocity.x > 0)
    {
        NSLog(@"gesture went right");
        if ([gestureRecognizer state] == UIGestureRecognizerStateBegan || [gestureRecognizer state] == UIGestureRecognizerStateChanged){
            if (adminView.frame.origin.x <= -10) {
                CGPoint translation = [gestureRecognizer translationInView:[adminView superview]];
                [adminView setCenter:CGPointMake([adminView center].x + translation.x, [adminView center].y)];
                [gestureRecognizer setTranslation:CGPointZero inView:[adminView superview]];
            }
        }
        else{
            if (adminView.frame.origin.x > -100) {
                [UIView beginAnimations:nil context:NULL];
                [UIView setAnimationDuration:0.5f];
                [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:adminView cache:YES];
                adminView.frame=CGRectMake(0, 0, 322, 748);
                [UIView commitAnimations];
            }
            else{
                [UIView beginAnimations:nil context:NULL];
                [UIView setAnimationDuration:0.5];
                [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:adminView cache:YES];
                adminView.frame=CGRectMake(-295, 0, 322, 748);
                [UIView commitAnimations];
            }
        }
    }
    else
    {
        NSLog(@"gesture went left");
        if ([gestureRecognizer state] == UIGestureRecognizerStateBegan || [gestureRecognizer state] == UIGestureRecognizerStateChanged){
            if (adminView.frame.origin.x > -200) {
                CGPoint translation = [gestureRecognizer translationInView:[adminView superview]];
                [adminView setCenter:CGPointMake([adminView center].x + translation.x, [adminView center].y)];
                [gestureRecognizer setTranslation:CGPointZero inView:[adminView superview]];
            }
        }
        else{
            if (adminView.frame.origin.x > -250) {
                [UIView beginAnimations:nil context:NULL];
                [UIView setAnimationDuration:0.5f];
                [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:adminView cache:YES];
                adminView.frame=CGRectMake(-295, 0, 322, 748);
                [UIView commitAnimations];
            }
            else{
                [UIView beginAnimations:nil context:NULL];
                [UIView setAnimationDuration:0.5];
                [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:adminView cache:YES];
                adminView.frame=CGRectMake(0, 0, 322, 748);
                [UIView commitAnimations];
            }
        }
    }
}

No comments:

Post a Comment