Thứ Sáu, 26 tháng 12, 2014

How to Sleep like a Baby

It’s 3:00 a.m. where are you? Most people would probably be asleep. However, for a large majority of people, it is near impossible for them to get a good nights rest. Without it, they are unable to focus well, they have low energy, and let’s face it, they are usually in a not so good mood. Is there anything that the sleep deprived can do in order to help give their body the much needed sleep it needs? Aside from counting sheep, which rarely works, try some of the suggestions below.

How to Sleep like a Baby

First, start out by examining your bedroom for sleep distractions. Sleep distractions would be such things as clutter, the color of the paint, the noise level, etc. If your room is painted in bright, electrifying colors, you may want to consider painting it a soothing cool color. A pale green or a soothing blue would be good choices. You can’t expect to be able to sleep if the paint in your bedroom is so bright that it looks like an airport runway.

If your room is cluttered, consider scheduling a spring cleaning day and get rid of all those unwanted sleep thieves. If a room is cluttered, it gives our mind more things to focus on and think about during the night instead of sleep. Your bedroom is supposed to be your sanctuary, and let’s face it, who wants piles of bills or junk mail in their sanctuary? Not too many people.

As far as the noise level goes, this is different for each person. Some people enjoy some form of noise while they sleep and may even purchase a noise machine, while others have to have quiet. If you fall into the latter category, try purchasing some heavy drapes to see if they block out any of the unwanted noise. While the drapes probably won’t get rid of every unwanted noise, you will notice a big difference.

Next, try not to exercise before going to bed. I’m not saying don’t exercise at all, because exercise is good for us, but we all know that exercise releases endorphins which amp us up. You can’t expect to be able to go to sleep if you feel like you could run a marathon. Try to keep exercise to either early in the mornings or to around four hours before bedtime. This will give your body time to calm down and will help you to drift off to sleep much easier.

Another suggestion to help you get a good nights sleep would be to take a nice warm bath just before you are ready to go to bed. The warm bath will not only help you to relax physically, but it will also give your brain some time to unwind as well. It doesn’t have to be a long bath, just 10 or 15 minutes should do the trick. As you are letting the water out of the tub, picture your troubles and cares being washed down the drain. A mind that is not burdened with troubles is a mind that can easily drift off to sleep.

Lighting is another issue that effects sleep. If your bedroom window lets the light of a nearby street light into your bedroom, you might want to try some of those room darkening curtains to eliminate that problem. If you can’t find any or can’t afford them, try putting a quilt up instead. If your curtain rods are sturdy, they will usually hold up the extra weight of the quilt. Either of these two things will help darken your bedroom and help you drift off to what could be the best nights sleep you’ve had in a while.

Of course, don’t forget to flip your mattress every so often to keep it from getting worn. However, if your mattress is not in good shape and you can’t afford to buy a new one (because we know they don’t come cheap), consider buying a mattress topper. This will give you the sense of a new mattress, but will cost you a fraction of the price. Toppers come in a variety of styles, and it is up to you to find the one that suits your needs.

The last tip, try and keep the temperature in your bedroom at a comfortable level. You don’t want the temperature too hot or too cold. You want it just right. Again, it is up to you, as an individual, to decide what your perfect temperature is. Try these few tips out and see if they help you get the peaceful nights slumber your body has been missing. Pleasant dreams sleep deprived.

Thứ Tư, 24 tháng 12, 2014

Love Christmas

Christmas is the gentlest, loveliest festival of the revolving year – and yet, 4 all that, when it speaks, its voice has strong authority.

Christmas is the one time of year when people of all religions come together to worship Jesus Christ.

At Christmas play and make good cheer, For Christmas comes but once a year.

Bells are ringing and everyone is singing, It’s Christmas! It’s Christmas! Wishing you a Merry Christmas and a Happy New Year.

Bells ring and the birds sing, May you get all the happiness that Christmas brings! Wishing you and your family a very Happy Christmas and a wonderful New Year.

Bless us Lord, this Christmas, with quietness of mind; Teach us to be patient and always to be kind.

Blessed is the season which engages the whole world in a conspiracy of love.

Christmas Quotes

A wish for peace and happiness at Christmas and throughout the New Year.

The gift of love. The gift of peace. The gift of happiness. May all these be yours at Christmas.

 May the good times and treasures of the present become the golden memories of tomorrow. Wishing you lots of love, joy and happiness. Merry Christmas!

May the Christmas season fill your home with joy, your heart with love and your life with laughter.

May this Christmas end the present year on a cheerful note and make way for a fresh and bright New Year. Here's wishing you a Merry Christmas and a Happy New Year!

May this Christmas end the present year on a cheerful note and make way for a fresh and bright New Year.

Here's wishing you a Merry Christmas and a Happy New Year!

May the good times and treasures of the present become the golden memories of tomorrow.

 Wishing you lots of love, joy and happiness. Merry Christmas!

May your Christmas sparkle with moments of love, laughter and goodwill, and may the year ahead be full of contentment and joy. Have a Merry Christmas.

As you relish the goodies, decorate every nook and corner of your home and enjoy the get-togethers... may the joy and festivities continue to radiate in your lives, long after Christmas is gone.  Merry Christmas! Happy New Year!

With all Good Wishes for Christmas and the New Yearmerry-christmas-card-01.

Give the Gift of Tech Support: 4 Super Simple iOS Maintenance Tips for iPhone & iPad

iOS Santa

How many times have you seen someone else’s iPhone, iPad, or iPod touch running an ancient version of iOS that is not backed up and has a million app updates waiting in the wings? It’s remarkably common for iOS hardware to go neglected by those who are less tech savvy, so if you’re heading to visit seldom seen relatives and friends this holiday, consider using your own knowledge to give the gift of tech support by performing some super simple maintenance on their iOS hardware!


We’re intentionally keeping it simple here, and thankfully iOS devices are pretty easy going in general so you don’t need to do anything too wild to keep things running well on most iPhones and iPads. The focus will be on four primary aspects; setting up device backups to iCloud, ditching ancient unused apps, updating the other apps to the newest versions, and updating iOS to the latest version available. By the way, if they have a Mac too, we’ve got some great advice for OS X as well.

1: Set Up iOS Backups to iCloud

Keeping regular backups is really good practice, and Apple makes it super easy for iOS devices thanks to iCloud. But many users don’t use this free backup service (up to 5GB, anyway), so you should take a moment to turn it on for them, then to do a manual backup:

  • Go to “Settings” and to “iCloud” *
  • Choose “Backup” and be sure ‘iCloud Backup’ is turned ON, then tap on “Back Up Now” to start a new manual backup to iCloud

Back up to iCloud in iOS

*If for some reason they do not have an iCloud / Apple ID account setup yet, take this opportunity to make one for them for their device. Just don’t forget to provide them with their login information and password, otherwise they’d need to recover it.

Do not skip backing up! If their backups are already turned on, start a backup manually to iCloud with “Back Up Now” so that you have a fresh one to use if it becomes necessary. This lets you revert back quickly just in case something goes terribly wrong, and the last thing you want to do is brick someones iOS device or give them a bigger problem, right? So back up, stuff rarely happens, but if and when it does, you’ll be glad you made a backup first.

Once the iPhone or iPad finishes backing up, you can then update to the newest iOS version and update their apps too.

2: Clean Out Their Junk Apps

Just about everyone with an iOS device has a handful (or many hands full) of junk iOS apps that they downloaded, opened once, and never touched again. This stuff just clutters up iOS and takes up space and if it doesn’t get use, it may as well be uninstalled. You’ll need to work with whoever owns the iPad or iPhone to figure out what apps these are and if they are critical or waiting for just the right opportunity, so don’t go ditching apps without asking.

Delete apps from iOS

Find out what they use and don’t use, and take action based on that. While you’re at it, you could even clean up their home screen… again if that’s OK with the device owner.

3: Update iOS Apps

The last time I picked up my extended families iPad, the App Store icon on the home screen had 87 app updates available. 87! They had never updated the apps on their iPad, but kept downloading new apps and adding to the backlog. Updating apps is almost always a good idea, with new features, bug fixes, and improved compatibility with the latest versions of system software, and it’s easy too:

  • Open the App Store and head to the “Updates” tab
  • Choose “Update All” (perhaps ask permission first, they may have a favorite app that they prefer an older version to, like many users who hoard the ancient Twitter for iPad client)

Update apps in iOS App Store

Updating a gazillion apps can take a while, so have some patience. when you’re done updating the apps, it’s time to update iOS!

4: Update iOS to the Newest Version Available

Updating most* hardware to the newest versions of iOS is good practice, bringing new features, bug fixes, and various feature improvements. Updating iOS should only be done after a device has been backed up, so be sure you completed a backup to iCloud (or iTunes) before doing this, and be sure the hardware is new enough to adequately run the latest iOS versions:

  • Go to “Settings” and to “General”
  • Choose “Software Update” and if there is an update available, download & install it

Download and install iOS updates

As long as the hardware is on the newer side, the latest versions of iOS should run great and be an improvement with new features and better performance.

* Notice “most” hardware is not ALL hardware, because many of the older iOS devices, for example an iPhone 4S, iPad 2, or iPad 3, do not always perform as well on iOS 8 and the newest iOS versions. Sometimes, older hardware will just run better with prior versions of system software. Since downgrading from iOS 8 is now impossible, if the person is happy with good old iOS 5 on their iPad 3 and aren’t missing out on some crucial feature that would greatly improve their life, they can stay put, no big deal… unless YOU are volunteering for their future tech support needs if they run into a problem, right? =) Use your own discretion here, but do be mindful of older hardware possibly degrading in performance with a new system update.

OK, iOS is Now Great, But What About Their Macs?

Last year we covered the lovely idea of gifting tech support to fix up someone else’s Mac, it’s still great advice so check it out here! There’s even some basic Windows advice in there too…

Do you have any particular maintenance tips for iOS that you want to share? Whether it’s basic or not, let us know in the comments!

Source : osxdaily[dot]com
post from sitemap

Thứ Ba, 23 tháng 12, 2014

What To Do If You Can Not Remember an Apple ID or Password

What to do if you Forgot an Apple ID

Forgetting the login and password to an Apple ID is not the best feeling in the world, particularly given how integral an Apple login is to the broader iOS and OS X experience. So, if you or someone else happens to forget an Apple ID or the password to an Apple account, what should you do? First, don’t freak out, we’re human and this stuff happens. Apple provides multiple ways to recover a forgotten ID login or password, and you can start the recovery process either directly on an iPhone, iPad, or iPod touch, Mac, Windows PC, or just about anything with a web browser.

The different processes described below will work to recover a forgotten Apple ID (meaning the email address used to login), and/or reset a forgotten Apple ID password. This can be particularly helpful if you’re setting up a new device for yourself or someone else, switching a device to a credit card-free ID, or changing the Apple ID associated with a device, and you can’t remember the pertinent login information, or if your email changed at some point and you didn’t update your Apple details to go along with it.

Before anything else, know that you can always contact Apple support directly here if you want assistance through official channels to regain account access, which may be the best option for users who are overwhelmed or confused.

Recover or Reset Forgotten Apple ID or Password on iPhone & iPad

This is all done on an iOS device and is often the simplest way to log back into an Apple account:

  1. Open the Settings app and scroll down and tap on “iCloud”
  2. Tap on the email address at the very top of the iCloud settings screen
  3. Tap on the blue text underneath the password entry that says “Forgot Apple ID or Password?” where you’ll have two choices:
    • If you know your Apple ID and don’t remember the password, type in your email address and click “Next” to start the reset process
    • If you don’t know your Apple ID, tap on “Forgot your Apple ID?” and fill out your full name and email address to recover the Apple ID login (yes, you can then do the password reset after you have the Apple ID)
  4. Answer the security questions pertaining to that Apple ID, and follow the onscreen directions to complete the process

At this point you should be good to go, you can reset the password for the account and then login as usual.

What if this doesn’t work, or what if it doesn’t find your Apple ID? You can try one of the next two options:

Find a Forgotten Apple ID by Email or Old Email Address

This is a more advanced trick to search multiple email addresses, which is incredibly helpful if you switched email accounts at some point in time and that’s what has caused the login problem. This can be done with any web browser in iOS, OS X, or Windows:

  1. Open the web browser of choice and go to this Apple iForgot website (creative name, eh?)
  2. Enter the first and last name associated with the Apple ID, your current email address, and any and all prior email addresses to start the reset process
  3. Answer the security questions associated with the user to complete the reset process

This will help to find the Apple ID, but if you can’t recall the password to that ID then you’d need to go to the next step as well.

Reset an Apple ID Password from the Web

You can also start the password reset process from the official Apple ID website, this also can be done any device as long as you have a web browser:

  1. Go to this Apple ID site and under “Manage your Apple ID” choose the “Reset your password” option
  2. Enter the email address associated with the account and answer the security questions as usual to complete the password reset process

Finally, if you’re completely stuck, you’re annoyed, confused, or none of the above has worked, you can contact Apple directly about your account and in many situations they can help you to regain access again.

Source : osxdaily[dot]com
post from sitemap

Thứ Hai, 22 tháng 12, 2014

How to Check for a Carrier Settings Update on iPhone

iPhone Carrier Settings Update available

From time to time, your cellular network provider or Apple may issue a carrier settings update to an iPhone or cellular iPad device. The updates are usually very small and make adjustments or improvements to carrier specific settings pertaining to the cell network, data, personal hotspot, voicemail, text messaging, or making calls. While you may see a carrier update pop up randomly on your iPhone, or a request to install one during a general iOS update, you can also manually check for these carrier updates on your own at any time.

Check For & Install Cellular Carrier Settings Updates in iOS

Carrier updates are usually quick and fairly inconsequential, though it’s still good policy to backup your iPhone before attempting to install one. This works the same on any cellular equipped iOS device, whether an iPhone or iPad:

  1. Open the “Settings” app and go to “General”
  2. Tap on “About” and wait a moment at the about screen, if a update is available you will see a popup window that says “Carrier Settings Update : New settings are available. Would you like to update them now?” with ‘Not Now’ and ‘Update’ as the two available options, tap on “Update” to install the carrier settings update onto the iPhone

The update screen looks something like this:

Carrier Settings Update on an iPhone

Installing the carrier update will make your cellular service cycle off for a moment and then back on, so you won’t want to try to install the update while you’re transferring data or in an important conversation, whether though a call, SMS, iMessage, or voice texting.

Though these are usually pushed and installed onto your iPhone when you update iOS, if you haven’t seen a carrier update in quite some time, it can be a good idea to check every once in a while to see if one is available. Sometimes they can even add new features to your iPhone, for example, a recent carrier settings update available to many iPhones on US cell providers offered the ability to change the data connection from LTE, 3G, or Edge, a feature that was made possible with an iOS update, but had to be specifically allowed by the carrier as well.

Source : osxdaily[dot]com
post from sitemap

Creating Simple Animations with Facebook’s Pop Framework

57 Flares 57 Flares ×

Editor’s note: When Facebook released its Paper app, it generated a lot of buzz in the app world. If you’ve used Paper before, the visual news feed reader, you should be amazed by its beautiful and fluid user interface. The design and attention to detail on the app is unmatched. The app refrains from using buttons and menus, but was built to be gesture-driven, to a degree that was uncommonly found in iOS apps at the time of its release. It went beyond Core Animation. The team has built its own animation engine to support all the smooth animations and coordinate animations with touch inputs. When I first tried out the app, I was wondering how some of the animations were implemented. Honestly I didn’t know how. A couple months later, the company open-sourced Pop, the animation engine behind its iOS Paper app. As a Facebook’s engineer described, Pop drives the scrolling, bouncing, and unfolding effects that bring Paper to life. Thanks to Facebook team. With the Pop framework, this means you can create similar animations that were found on Paper in your own apps.

The Pop framework was first released in late April, 2014. So far we haven’t written any tutorials about the framework. Thanks to Hossam who is kind enough to share with us an introduction of POP and show us how to create a few simple animations.

Enter the Pop tutorial.

pop-animations

In this tutorial, we will talk about Facebook POP framework to make great and easy animations in your own iOS apps. Like any other tutorials on AppCoda, I will help you understand and master Pop by examples. We will create four simple animations together to explore the framework.

Pop is an extensible animation engine for both iOS and OS X. In addition to basic animations including Linear, Ease-In, Ease-Out, Ease-In-Ease-Out animations, it supports spring (at the time of its release, spring animation was not supported in iOS), decay and custom animations:

  • Spring – dynamic animation that creates a nice bouncing effect.
  • Decay – dynamic animation that brings a movement to a smooth halt.
  • Custom – because the engine is designed to be extensible, you can create your own custom animations.

The fundamental animation type of Pop is a POPAnimation. You can think of it as the abstract or base class of all POP animations. The Pop interface is implemented as an addition of category on NSObject. This allows any object to be animated.

pop-category

The Pop API is very developer friendly that lets you easily build some realistic, physics-based interactions. For instance, here is the code snippet for creating a spring animation on a text label:

1
2
3
4
5
POPSpringAnimation *sprintAnimation = [POPSpringAnimation animationWithPropertyNamed :kPOPViewScaleXY ];
sprintAnimation.toValue = [ NSValue valueWithCGPoint :CGPointMake ( 0.9, 0.9 ) ];
sprintAnimation.velocity = [ NSValue valueWithCGPoint :CGPointMake ( 2, 2 ) ];
sprintAnimation.springBounciness = 20.f;
[self.textLabel pop_addAnimation :sprintAnimation forKey : @ "springAnimation" ];

Easy, right? Let’s get started and create the demo app. I’m sure you’ll have a better understanding of Pop after going through the project.

Using Pop Framework

If you use CocoaPods, you can just add the following to your project Podfile:

pod ‘pop’, ‘~> 1.0′

For non-CocoaPods project, you can download the Pop framework here and add the “pop” folder to your workspace. Go to your project and ensure the “Other Linker Flags” option is added with -lc++ under Build Settings.

using-pop-framework-hd

Also set the Header Search Path to the correct folder. For instance, I used to put the “pop” framework under a “Library” folder. You can set the Header Search Path to “$(SRCROOT)/Library”. To use the framework, you can just add the following import statement in your source code:

1
#import <pop/POP.h>

Once you added the framework, create a simple table view like below. It’s just a simple table displaying three rows:

sample-pop-app

If you don’t want to start from scratch, you can download the starter project here.

Example #1: UITableViewCell Animation

For the first example, we will create animations on the table view cells. We will add a basic scale up animation when a user highlights a cell. When releasing, we will scale it back using spring animation.

Go to ExampleCell.m and override the setHighlighted: method using the code snippet below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
- ( void )setHighlighted : ( BOOL )highlighted animated : ( BOOL )animated
{
    [super setHighlighted :highlighted animated :animated ];
    if (self.highlighted ) {
        POPBasicAnimation *scaleAnimation = [POPBasicAnimation animationWithPropertyNamed :kPOPViewScaleXY ];
        scaleAnimation.duration = 0.1;
        scaleAnimation.toValue = [ NSValue valueWithCGPoint :CGPointMake ( 1, 1 ) ];
        [self.textLabel pop_addAnimation :scaleAnimation forKey : @ "scalingUp" ];
       
       
       
    } else {
        POPSpringAnimation *sprintAnimation = [POPSpringAnimation animationWithPropertyNamed :kPOPViewScaleXY ];
        sprintAnimation.toValue = [ NSValue valueWithCGPoint :CGPointMake ( 0.9, 0.9 ) ];
        sprintAnimation.velocity = [ NSValue valueWithCGPoint :CGPointMake ( 2, 2 ) ];
        sprintAnimation.springBounciness = 20.f;
        [self.textLabel pop_addAnimation :sprintAnimation forKey : @ "springAnimation" ];
    }
}

It is pretty straightforward to use Pop. You first choose a particular type of animation. Like the above example, we pick the POPBasicAnimation when the cell is highlighted and POPSpringAnimation when the user lifts up his/her finger. Once you select the type of animation, the second thing is to provide the animation properties. For both animations, we specify the kPOPViewScaleXY property for scaling the label. Next, we specify toValue which describes your desired end state of the animation. In the above, we set to CGPointMake(1, 1) that scales the object with a value of one. Depending on the type of animation you’re creating, you’ll have to configure addition settings like springBounciness in spring animations that controls the bouncing effect. Lastly, we add the animation to the text label and give it a name (e.g. springAnimation).

Note: Pop provides a number of predefined properties for creating animations. You can find out the properties by referring to the POPAnimatableProperty.h.

Now build and run the app. Highlight any cell and release it to test the animation.

pop-animation-1-1

Example #2: Animating a Like Button

Have you used the Facebook Messenger app? I really like the animation of the Send/Like button when you start to type message to a friend. I decided to use Pop to create a similar animation.

First, create a new view controller in the storyboard. In the view controller, create a text field for comments. Then add a Send and Like buttons. You can download the Like button image here and import it to the image asset. Just place the Like button over the Send button. Later we will write some code to display one of the buttons at a time. By default, the Like button will be displayed. When a user keys in a comment, we will hide the Like button and display the Send button with an animation.

facebook-send-ui-design-hd

Lastly, connect the example list view controller with Facebook Like view controller by using a manual segue. Set the identifier of the segue as “openFB”. Later we’ll use code to trigger the segue.

Once you designed the user interface, create a new class called FacebookButtonAnimationViewController and set it as the custom class of the view controller.

Next, create the outlet variables for both Like and Send buttons, as well as, the text field. Your outlet variable should look like this:

1
2
3
4
5
6
@interface FacebookButtonAnimationViewController ( )
@property (weak, nonatomic ) IBOutlet UIButton *likeButton;
@property (weak, nonatomic ) IBOutlet UIButton *sendButton;
@property (weak, nonatomic ) IBOutlet UITextField *msgTextField;

@end

In FacebookButtonAnimationViewController.h, import POP.h and implement the UITextFieldDelegate:

1
2
3
4
5
6
#import <UIKit/UIKit.h>
#import <pop/POP.h>

@interface FacebookButtonAnimationViewController : UIViewController <UITextFieldDelegate>

@end

In the viewDidLoad method of FacebookButtonAnimationViewController.m, insert the following line of code to set the delegate of text field and hide the Send button:

1
2
self.msgTextField.delegate = self;
self.sendButton.hidden = YES;

Now we will implement the methods for handling the text field. Insert these methods in the same file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
- ( BOOL )textField : (UITextField * )textField shouldChangeCharactersInRange : ( NSRange )range replacementString : ( NSString * ) string {
   
    NSString *comment;
   
    if (range.length == 0 ) {
        comment = [ NSString stringWithFormat : @ "%@%@", textField.text, string ];
    } else {
        comment = [textField.text substringToIndex :textField.text.length - range.length ];
    }
   
    if (comment.length == 0 ) {
        // Show Like
        [self showLikeButton ];
    } else   {
        // Show Send
        [self showSendButton ];
    }
   
    return YES;
}

The shouldChangeCharactersInRange method is called every time when whenever the user types a new character or delete a character in the text field. If the text field is empty, we display the Like button. On the other hand, if the text field contains any characters, we display the Send button.

Next, we implement both showLikeButton and showSendButton methods:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
- ( void )showSendButton {
    if (self.sendButton.isHidden ) {
        self.likeButton.hidden = YES;
        self.sendButton.hidden = NO;
       
        POPSpringAnimation *sprintAnimation = [POPSpringAnimation animationWithPropertyNamed :kPOPViewScaleXY ];
       
        sprintAnimation.velocity = [ NSValue valueWithCGPoint :CGPointMake ( 8, 8 ) ];
        sprintAnimation.springBounciness = 20.f;
        [self.sendButton pop_addAnimation :sprintAnimation forKey : @ "sendAnimation" ];
    }
}

- ( void )showLikeButton {
    self.likeButton.hidden = NO;
    self.sendButton.hidden = YES;
   
    POPSpringAnimation *spin = [POPSpringAnimation animationWithPropertyNamed :kPOPLayerRotation ];
   
    spin.fromValue = @ (M_PI / 4 );
    spin.toValue = @ ( 0 );
    spin.springBounciness = 20;
    spin.velocity = @ ( 10 );
    [self.likeButton.layer pop_addAnimation :spin forKey : @ "likeAnimation" ];
}

In the showSendButton method, we hide the Like button and show the Send button, and then apply a spring animation with the kPOPViewScaleXY property on the Send button.

The same technique is used for the Like button but we apply a rotation animation instead. We first create an instance of POPSpringAnimation and then set the “from” and “to” values. The Like button is rotated from 45 degrees (i.e. M_PI/4) to 0 degree with bounciness set to 20.

Lastly, insert the following method in ExamplesListViewController.m to trigger the segue:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- ( void )tableView : (UITableView * )tableView didSelectRowAtIndexPath : ( NSIndexPath * )indexPath
{
    switch (indexPath.row ) {
        case 0 :
            [self performSegueWithIdentifier : @ "openFB" sender :self ];
            break;
        case 1 :
            [self performSegueWithIdentifier : @ "openWrongPass" sender :self ];
            break;
        case 2 :
            [self performSegueWithIdentifier : @ "openCustomTransition" sender :self ];
            break;
           
        default :
            break;
    }
}

Now it is ready to test the app. Hit the Run button and key in a character in the text field to test the animation.

pop-animation-2

Example #3: Wrong Password Animation

As a Mac user, you should be very familiar with the password field in Mac OS X. When you type a wrong password during login, the text field shakes. In this example, we’ll use Pop to replicate the animation.

First, go to Interface Builder and add a new view controller. Then add a text field and a Login button. Again, create a manual segue between the Example List View Controller and the new view controller. Set the segue’s identifier to “openWrongPass”. Your user interface should be similar to this:

pop-wrong-password-ui-hd

Next, create a new class called WrongPasswordViewController and set it as the custom class of the new view controller. Create an outlet variable for the text field and name it passwordTextField.

1
2
3
4
@interface WrongPasswordViewController ( )
@property (weak, nonatomic ) IBOutlet UITextField *passwordTextField;

@end

Then we create an action method named “login” for the Login button.

As said before, we will apply a “shake” animation on the text field to indicate a wrong password. For demo purpose, we will not verify the password. We will just show the animation whenever the user clicks the Login button.

Implement the login method like this:

1
2
3
4
5
6
7
8
9
10
- (IBAction )login : ( id )sender {
   
    POPSpringAnimation *shake = [POPSpringAnimation animationWithPropertyNamed :kPOPLayerPositionX ];
   
    shake.springBounciness = 20;
    shake.velocity = @ ( 3000 );
   
    [self.passwordTextField.layer pop_addAnimation :shake forKey : @ "shakePassword" ];

}

The above code is pretty straightforward. We create the POPSpringAnimation with the kPOPLayerPositionX property. This property simply moves the text field along the X axis.

Lastly, remember to import the POP.h at the beginning of the WrongPasswordViewController.m:

1
#import <pop/POP.h>

Cool! Compile and run the app to test the animation.

pop-animation-3-2

Example #4: Custom View Controller Transition

In the last example, I will show you how to present a view controller with a custom animation. We will a view controller with a single button “Present”. When a user taps the button, the app presents another view controller modally with a custom animation. Since iOS 7, you can customise the view transition by using the transitioningDelegate of UIViewController. The delegate, which should conform to UIViewControllerAnimatedTransitioning, provides the transition animator that animates the transition of view controllers.

First, create two view controllers in the storyboard and two new classes. Name one class “CustomVCTransitionViewController” and the other “CustomModalViewController”. Set these classes as the custom class of the controllers. For the modal view controller (in red), set the storyboard ID to “customModal”. Further, connect the Example List View Controller with the CustomVCTransitionViewController using a manual segue. Set the identifier of the segue to “openCustomTransition”.

Your UI design should look like this:

custom-view-controller-ui-hd

You can have a quick test of the app. When you select Custom VC Transition, the CustomVCTransitionController should appear.

Now we’ll implement the CustomVCTransitionViewController to handle the Present button. Insert the following line of code in CustomVCTransitionViewController.h to adopt the UIViewControllerTransitioningDelegate protocol:

1
@interface CustomVCTransitionViewController : UIViewController <UIViewControllerTransitioningDelegate>

In CustomVCTransitionViewController.m, add the following lines of code to import the header files:

1
2
3
4
#import "CustomModalViewController.h"
#import "PresentingAnimationController.h"
#import "DismissingAnimationController.h"
#import <pop/POP.h>

Then insert the following methods to implement the action method of the Present button and the required methods of the protocol:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
- (IBAction )didClickOnPresent : ( id )sender {
   
    CustomModalViewController *modalVC = [self.storyboard instantiateViewControllerWithIdentifier : @ "customModal" ];
   
   
    modalVC.transitioningDelegate = self;
   
    modalVC.modalPresentationStyle = UIModalPresentationCustom;
   
    [self.navigationController presentViewController :modalVC animated : YES completion : nil ];
}

#pragma mark - UIViewControllerTransitionDelegate -

- ( id <UIViewControllerAnimatedTransitioning> )animationControllerForPresentedController : (UIViewController * )presented presentingController : (UIViewController * )presenting sourceController : (UIViewController * )source
{
    return [ [PresentingAnimationController alloc ] init ];
}

- ( id <UIViewControllerAnimatedTransitioning> )animationControllerForDismissedController : (UIViewController * )dismissed
{
    return [ [DismissingAnimationController alloc ] init ];
}

When the button is tapped, the didClickOnPresent method will be invoked. Here we instantiate the modal view controller and set the transitioning delegate to the current view controller. We also set the modal presentation style to custom. (With the action method, remember to establish a connection between the Present button and the method in storyboard.)

As the class adopts the UIViewControllerTransitioningDelegate protocol, we implement the two required methods. The animationControllerForPresentedController: method returns the transition animator object to use when presenting the modal view controller. Conversely, the animationControllerForDismissedController: method provides the animator object for dismissing a view controller.

We haven’t created both animator classes yet. Now create a new class called PresentingAnimationController, set it as a subclass of NSObject and adopt the UIViewControllerAnimatedTransitioning protocol:

1
2
3
4
#import <UIKit/UIKit.h>
#import "POP.h"

@interface PresentingAnimationController : NSObject <UIViewControllerAnimatedTransitioning>

In PresentingAnimationController.m, add the following methods:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
- (NSTimeInterval )transitionDuration : ( id <UIViewControllerContextTransitioning> )transitionContext {
    return 0.5f;
}

- ( void )animateTransition : ( id <UIViewControllerContextTransitioning> )transitionContext {
   
    UIView *fromView = [transitionContext viewControllerForKey :UITransitionContextFromViewControllerKey ].view;
    fromView.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed;
    fromView.userInteractionEnabled = NO;
   
    UIView *toView = [transitionContext viewControllerForKey :UITransitionContextToViewControllerKey ].view;
    toView.frame = CGRectMake ( 0,
                              0,
                              CGRectGetWidth (transitionContext.containerView.bounds ) - 100.f,
                              CGRectGetHeight (transitionContext.containerView.bounds ) - 280.f );
    CGPoint p = CGPointMake (transitionContext.containerView.center.x, -transitionContext.containerView.center.y );
    toView.center = p;
   
    [transitionContext.containerView addSubview :toView ];
   
    POPSpringAnimation *positionAnimation = [POPSpringAnimation animationWithPropertyNamed :kPOPLayerPositionY ];
    positionAnimation.toValue = @ (transitionContext.containerView.center.y );
    positionAnimation.springBounciness = 10;
    [positionAnimation setCompletionBlock :^ (POPAnimation *anim, BOOL finished ) {
        [transitionContext completeTransition : YES ];
    } ];
   
    POPSpringAnimation *scaleAnimation = [POPSpringAnimation animationWithPropertyNamed :kPOPLayerScaleXY ];
    scaleAnimation.springBounciness = 20;
    scaleAnimation.fromValue = [ NSValue valueWithCGPoint :CGPointMake ( 1.2, 1.4 ) ];
   
    [toView.layer pop_addAnimation :positionAnimation forKey : @ "positionAnimation" ];
    [toView.layer pop_addAnimation :scaleAnimation forKey : @ "scaleAnimation" ];
   
}

The first method defines the transition duration (i.e. 0.5 seconds). To animate the transition, we implement the animateTransition: method. Here we define how the transition animations are performed. We first retrieve the “fromView” involved in the transition using the viewControllerForKey: method of the transitionContext. Next, we retrieve the “toView”. Once you have these two views, you can apply any animations during the view transition. Here we apply two animations – position animation and scale animation. The position animation slides the view from the top of the screen to the center. The scale animation scales up the view a bit and then scales it back to the normal values.

Next, create a new class named DismissingAnimationController and adopt the UIViewControllerAnimatedTransitioning protocol:

1
2
3
4
5
6
7
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <pop/POP.h>

@interface DismissingAnimationController : NSObject <UIViewControllerAnimatedTransitioning>

@end

Similarly, we create the dismissing animation by implementing the required method of the UIViewControllerAnimatedTransitioning protocol:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
- (NSTimeInterval )transitionDuration : ( id <UIViewControllerContextTransitioning> )transitionContext {
    return 0.5f;
}

- ( void )animateTransition : ( id <UIViewControllerContextTransitioning> )transitionContext {
   
    UIView *toView = [transitionContext viewControllerForKey :UITransitionContextToViewControllerKey ].view;
    toView.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;
    toView.userInteractionEnabled = YES;
   
    UIView *fromView = [transitionContext viewControllerForKey :UITransitionContextFromViewControllerKey ].view;
   
   
    POPBasicAnimation *closeAnimation = [POPBasicAnimation animationWithPropertyNamed :kPOPLayerPositionY ];
    closeAnimation.toValue = @ ( -fromView.layer.position.y );
    [closeAnimation setCompletionBlock :^ (POPAnimation *anim, BOOL finished ) {
        [transitionContext completeTransition : YES ];
    } ];
   
    POPSpringAnimation *scaleDownAnimation = [POPSpringAnimation animationWithPropertyNamed :kPOPLayerScaleXY ];
    scaleDownAnimation.springBounciness = 20;
    scaleDownAnimation.toValue = [ NSValue valueWithCGPoint :CGPointMake ( 0, 0 ) ];
   
    [fromView.layer pop_addAnimation :closeAnimation forKey : @ "closeAnimation" ];
    [fromView.layer pop_addAnimation :scaleDownAnimation forKey : @ "scaleDown" ];
   
}

When dismissing the modal view, we apply two animations – close animation and scale down animation. By combining both animations, we make the modal view disappear or move off screen.

Go back to the CustomModalViewController.m, update the viewDidLoad method and implement the didClickOnClose method:

1
2
3
4
5
6
7
8
9
10
- ( void )viewDidLoad {
    [super viewDidLoad ];
   
    // Round corner
    self.view.layer.cornerRadius = 8.f;
}

- (IBAction )didClickOnClose : ( id )sender {
    [self dismissViewControllerAnimated : YES completion : nil ];
}

Finally, establish a connection between the Close button with the didClickOnClose method in InterfaceBuilder.

Cool! It’s ready to test the app. Run it and test the view transition.

pop-animation-4

Summary

In this tutorial, I gave you an introduction of Facebook’s Pop framework. As you can see, the animation engine is pretty easy to use. If you understand the animation techniques covered in the tutorial, you should be able to create your own animation in your apps.

For your reference, you can download the complete Xcode project here. Or you can check out the project on Github.

What do you think about the tutorial? Leave me comment and share your thought.

Source : appcoda[dot]com
post from sitemap

Chủ Nhật, 21 tháng 12, 2014

How to Use Audio Messages in iOS to Send Voice Texts from iPhone

Voice Texts and Audio Messages in iOS Audio Messages (also called Voice Texts) are a great new feature in iOS that allows you to send a quick little audio note from your iPhone to another iPhone, iPad, or Mac user who has the Messages app configured to use iMessages. This can not only be an added fun way to communicate, but it can also be a nice way to have a more personable and casual conversation that isn’t particularly time sensitive, since hearing someones voice is a bit more meaningful than reading text (unless packed with emoji, maybe).


The iOS Audio Message feature is easy to use but can cause a fair amount of confusion while first encountering it, even while figuring it out, since the interface to record, stop recording, playback, and send messages is a bit different from anything else in iOS. Follow along and try it out yourself, you’ll get the hang of it shortly.

You’ll need iOS 8 or newer installed to have this feature, prior versions do not include audio texting support.

How to Send, Playback, and Cancel Voice & Audio Texts in Messages for iOS

  1. From the Messages app, either create a new iMessage or open an existing iMessage thread*
  2. Tap and hold on the microphone icon to record a voice message – continue holding while recording
  3. Record an audio message in iOS

  4. Release the microphone icon when finished recording and you have three options:
    • Tap on the upward facing arrow icon to send the audio note
    • Tap the (X) button to cancel and delete the audio note
    • Tap the > play button to playback the audio message and listen to it without sending

    Audio message controls in iOS

  5. Once the audio message has been sent, it will be playable by both yourself and the recipient(s) in the message thread window until it expires (note you can change the audio note expiration setting or turn off the auto-delete audio and video messages option in iOS settings)

This is what an audio message looks like when it has been sent, being on the receiving end of a voice text looks pretty much identical too.

Audio message in iOS

Tapping on the (>) play button will play the message, which will automatically delete after a few moments unless that has been changed in the settings.

The key is to use a tap-and-hold, simply tapping the microphone icon will not do anything. Also, if you tap and hold but move your finger up, you may accidentally send the audio message before you wanted to or before you finished recording. The feature is really easy to use, but the way it works has led to a fair amount of confusion with some users and likely a large amount of accidental voice messages as well.

* Note if you’re looking to send an audio note, the recipient must be using iMessage, either on an iPhone, iPad, iPod touch, or Mac, otherwise the microphone icon will not appear next to the message input box

Users can also send and receive audio messages from a Mac running modern versions of OS X, and the feature works quite similar on the Mac both when recording, sending, and playing back audio messages.

Try it out yourself, you’ll likely find it to be a new fun way to communicate. If you want to see the voice texting feature in action, you can also catch it in this iPhone 6 commercial which prominently featured the iOS audio messaging feature being used in a humorous manner.

Source : osxdaily[dot]com
post from sitemap