Friday, 17 July 2015

Mpmovieplayerviewcontroller support Landscape.

In the application Delegate file.
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{

    if ([NSStringFromClass([[self.window.rootViewController presentedViewController] class]) isEqualToString:@"MPInlineVideoFullscreenViewController"]&&[self.window.rootViewController presentedViewController].isBeingDismissed)
    {
        return UIInterfaceOrientationMaskPortrait;
    }
    if ([NSStringFromClass([[self.window.rootViewController presentedViewController] class]) isEqualToString:@"MPInlineVideoFullscreenViewController"])
        return UIInterfaceOrientationMaskAll;
    else
        return UIInterfaceOrientationMaskPortrait;

}

Tuesday, 9 June 2015

Cocopods Installation Progress.

For installing Cocopods
sudo gem install cocoapods -V

For installing pods
pod install --verbose 

You can run pod install --no-repo-update if you do not want to perform a repo update.

Monday, 1 June 2015

Device check and Screen size

#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)

#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
#define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT))

#define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)
#define IS_IPHONE_5 (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0)
#define IS_IPHONE_6 (IS_IPHONE && SCREEN_MAX_LENGTH == 667.0)
#define IS_IPHONE_6P (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0)

Thursday, 30 April 2015

Drag and Drop View

#import "DragView.h"
@implementation DragView
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{

    CGPoint touchPoint = [[touches anyObject] locationInView:self];
    CGPoint previousPoint = [[touches anyObject] previousLocationInView:self];
    CGFloat xChange=touchPoint.x-previousPoint.x;
    CGFloat yChange=touchPoint.y-previousPoint.y;
    float newX=self.frame.origin.x+xChange;
    float newY=self.frame.origin.y+yChange;
    self.frame=CGRectMake(newX, newY, self.frame.size.width, self.frame.size.height);

}
@end

Friday, 17 April 2015

UITextView detect hashtag

// TextView Delegate Function

- (void)textViewDidChange:(UITextView *)textView{
    NSLog(@"textViewDidChange:");

    textView.scrollEnabled = NO;
    NSRange selectedRange = textView.selectedRange;
    NSString *text = textView.text;

    // This will give me an attributedString with the base text-style
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:text];

    NSError *error = nil;
    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"#(\\w+)" options:0 error:&error];
    NSArray *matches = [regex matchesInString:text
                                      options:0
                                        range:NSMakeRange(0, text.length)];

    for (NSTextCheckingResult *match in matches)
    {
        NSRange matchRange = [match rangeAtIndex:0];
        [attributedString addAttribute:NSForegroundColorAttributeName
                                 value:[UIColor blueColor]
                                 range:matchRange];
    }

    textView.attributedText = attributedString;
    textView.selectedRange = selectedRange;
    textView.scrollEnabled = YES;

}