Thursday, May 22, 2014

setting RGB colors in iPhone app



#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]


self.backgroundColor=UIColorFromRGB(0x212221);

Wednesday, May 21, 2014

iphone textfield font size adjustment

CGFloat yourSelectedFontSize = 17.0 ;
    UIFont *yourNewSameStyleFont = [textField.font fontWithSize:yourSelectedFontSize];

    [textField setFont:yourNewSameStyleFont];

Wednesday, May 14, 2014

iphone changing view size on keyboard appearance

NSDictionary* info = [notification userInfo];
       CGSize keyboardSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKeyCGRectValue].size;
        self.textNoteView.frame = CGRectMake(self.textNoteView.frame.origin.xself.textNoteView.frame.origin.yself.textNoteView.frame.size.widthself.textNoteView.frame.size.height - keyboardSize.height);

Checking orientation in iphone

 UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
    if (UIInterfaceOrientationIsPortrait(interfaceOrientation))
    {
       

    }

Thursday, May 8, 2014

Release audio mic or other stuff when iPhone app goes to background keeping them in Background mode in plist

// Tell iOS this as a background task in case we get backgrounded
UIBackgroundTaskIdentifier taskId = [[UIApplication sharedApplication] 
          beginBackgroundTaskWithExpirationHandler:NULL];

//----------------------------------------------
// Perform your  operations here
//----------------------------------------------


// Tell iOS that we are done with stuff that needed to keep going even if backgrounded    
[[UIApplication sharedApplication] endBackgroundTask:taskId];

Wednesday, May 7, 2014

Event that is called when textfield got selected in iPhone

-(void)textFieldDidBeginEditing:(UITextField *)textField { //Keyboard becomes visible

    //perform actions.
}

Also have to set delegate self
self.mField.delegate=self;
@interface YourViewController : ViewController<UITextFieldDelegate>

Tuesday, May 6, 2014

Multiple views and dragging in Apple IOS for iphone

good tutorial is at
http://ios-blog.co.uk/tutorials/create-multiple-views-and-make-the-touched-view-follow-the-users-touch/

youtube video in iphone

http://stackoverflow.com/questions/15717754/objective-c-how-to-autoplay-a-youtube-video-in-a-uiwebview

Disappearing Keyboard on iPhone on touching anywhere on the UIView

#pragma mark - allow keyboard to dismiss by tapping anywhere not otherwise tappable on the view
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    LogDebug(@"touchesBegan:withEvent:");
    
  
   //-------------
  
    [super touchesBegan:touches withEvent:event];

}

Schedule Timer on iPhone apps

Function nameOfTheFunctionToBeCalled will be called after 6 secs.

NSTimeInterval timeInterval = 6; //seconds
        [NSTimer scheduledTimerWithTimeInterval:timeInterval
                                         target:self
                                       selector:@selector(nameOfTheFunctionToBeCalled)
                                       userInfo:nil

                                        repeats:NO];


iPhone goes to sleep even with idleTimerdisabled=YES

Find the solution from here

If your application is using camera then app will go to sleep after using camera . So you need to add UIRequiredDeviceCapabilities in your app plist . Different devices you can add as shown here


After camera access, idletimerdisabled setting changed back to original



Monday, May 5, 2014

Changing Text Color of UICollectionViewCell on selection programmatically

Have to overwrite the setSelected method of UICollectionView Class. Don't forget to call super as well. 

-(void)setSelected:(BOOL)selected{
    [super setSelected:selected];
    if (selected) {
       self.tagLabel.textColor=[UIColor blackColor];
    }
    else
        
     self.tagLabel.textColor=[UIColor lightTextColor];
    

}