Saturday, 12 April 2014

Tuesday, 18 February 2014

How to popovercontroller in iphone?

  • Create a category to make popover available on iPhone.
//UIPopover+Iphone.h
@interface UIPopoverController (overrides)
+ (BOOL)_popoversDisabled;
@end
//UIPopover+Iphone.
@implementation UIPopoverController (overrides)
+ (BOOL)_popoversDisabled { return NO;
}

  • Create the button which will show the popover and implement the method it calls
- (void)viewDidLoad {
   yourButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [yourButton addTarget:self
                action:@selector(showPop:)
      forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview: yourButton];
}

-(void)showPop:(UIButton *)button {
   UIViewController *detailsViewController = [[DetailsViewController alloc] initWithNibName:@"DetailsViewController" bundle:nil];
   poc = [[UIPopoverController alloc] initWithContentViewController:detailsViewController];
   [poc setDelegate:self];
   [poc presentPopoverFromRect:_detailButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
}

also you can popover from UIBarButton.

[popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

Wednesday, 31 October 2012

How to check Device is iphone 4 or iphone 5

  float height = [UIScreen mainScreen].bounds.size.height;
   
    if (height==568) {
        self.deviceType = 5;
    }
    else
    {
        self.deviceType = 4;
    }

Tuesday, 11 September 2012

How to use uiview in subviews in iphone sdk

for (UITextField *txt in ViewPost.subviews)
    {
        if ([txt isKindOfClass:[UITextField class]])
        {
            if (txt.tag==index)
            {
                txt.text = appDelegate.answerDynamic;
                [appDelegate.arrAnswer addObject:appDelegate.answerDynamic];
                NSLog(@"%@",appDelegate.arrAnswer);
            }
        }

    }

Sunday, 1 July 2012

How to make splash screen animation in iphone sdk

- (void)loadView
{
    // If you create your views manually, you MUST override this method and use it to create your views.
    // If you use Interface Builder to create your views, then you must NOT override this method.
   
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        _animationBookCoverView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default.png"]];
    }
    else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {         
        if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation))
        {
            _animationBookCoverView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default-Landscape.png"]];           
        }
        else
        {
            _animationBookCoverView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default-Portrait.png"]];
        }
    }
   
    // Offset by the status bar on iPad. We don't on iPhone because splashscreens take up the full height.
    // No idea why Apple did this differently for iPhone and iPad.
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        _animationBookCoverView.frame = CGRectMake(0, 20,
                                                   _animationBookCoverView.frame.size.width,
                                                   _animationBookCoverView.frame.size.height);
    }
   
    self.view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
    self.view.backgroundColor = [UIColor clearColor];
    _animationBookCoverView.backgroundColor = [UIColor clearColor];
   
    [self.view addSubview:_animationBookCoverView];
   
    // Credit to this smart cookie:
    // http://mo7amedfouad.com/2011/12/book-cover-flip-animation-like-in-path-app/
   
    _animationBookCoverView.layer.anchorPoint = CGPointMake(0, .5);
    _animationBookCoverView.center = CGPointMake(_animationBookCoverView.center.x - _animationBookCoverView.bounds.size.width/2.0f, _animationBookCoverView.center.y);
    [UIView beginAnimations:@"openBook" context:nil];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
    [UIView setAnimationDuration:3.0];
    [UIView setAnimationDelay:0];
    CATransform3D _3Dt = CATransform3DIdentity;
    _3Dt = CATransform3DMakeRotation(M_PI/2.0, 0.0f, -1.0f, 0.0f);
    _3Dt.m34 = 0.001f; // Perspective
   
    _animationBookCoverView.layer.transform = _3Dt;
    [UIView commitAnimations];
   
    // Super hack. Adding a view to the window in Landscape on an iPad just doesn't work.
    // Used this guy's approach to manually rotate it:
    // http://stackoverflow.com/questions/1484799/only-first-uiview-added-view-addsubview-shows-correct-orientation/2694563#2694563
    // And then I learned that LandscapeLeft and PortraitUpsideDown need to be rotated an extra 180
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        CGAffineTransform rotate;
       
        if (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight)
        {
            rotate = CGAffineTransformMakeRotation(M_PI/2.0);
        }
        else if (self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
        {
            rotate = CGAffineTransformMakeRotation(M_PI);
        }
        else if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
        {
            rotate = CGAffineTransformMakeRotation(1.5 * M_PI);
        }
        else
        {
            // UIInterfaceOrientationPortrait - Only one that works without hacks
            return;
        }
       
        [self.view setTransform:rotate];
        self.view.frame = CGRectMake(0, 0, 1024, 768);
    }
}

- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag context:(void *)context
{
    [self.view removeFromSuperview];
}

Wednesday, 20 June 2012

diffrent iphone demos for learning......20-6

http://iphone-example.blogspot.in/

//////////////////////////////////////////////////////////////

http://www.icodeblog.com/

//////////////////////////////////////////////////////////////////

http://goaheadwithiphonetech.blogspot.in/

/////////////////////////////////////////////////////

http://ilarump.blogspot.in/

////////////////////////////////////////////////

http://maheshbabuiphonedeveloper.blogspot.in/

For learning iphone programming for diffrent demos

http://ranga-iphone-developer.blogspot.in/

http://ved-dimensions.blogspot.in/

http://beginnersiosdev.blogspot.in/