Showing posts with label objective C. Show all posts
Showing posts with label objective C. Show all posts

Monday, 3 March 2014

Using fontawesome for objective-C iOS Developer

If you like to use fontawesome in your objective C App, I have find a perfect project on github, this is the link:

https://github.com/alexdrone/ios-fontawesome


FontAwesome+iOS

Font awesome is an iconic font. Read more about it on http://fortawesome.github.com/Font-Awesome/
This category brings this great iconic font on iOS.

Usage

First, make sure you have FontAwesome.ttf bundled in your project and that UIAppFonts key in the project's plist file contains a String item named FontAwesome.ttf Then add the NSString+FontAwesome category to the project.
UILabel *label = [...]
label.font = [UIFont fontWithName:kFontAwesomeFamilyName size:20];
You can now use enums for all the different iconic characters
label.text = [NSString fontAwesomeIconStringForEnum:FAGithub];
or you can reference them by using the class identifiers listed here http://fortawesome.github.com/Font-Awesome/#all-icons
label.text = [NSString fontAwesomeIconStringForIconIdentifier:@"fa-github"];
That's it! For further information have a look to the small demo project!

FAImageView

FAImageView is now extended and contains a new property called defaultView that is shown when the image is set to nil. It is possible to use one the font-awesome icon as a default placeholder for an image view.
FAImageView *imageView = [[FAImageView alloc] initWithFrame:CGRectMake(0.f, 0.f, 100.f, 100.f)];
imageView.image = nil;
[imageView setDefaultIconIdentifier:@"fa-github"];

License

This project uses the FontAwesome fix made by Pit Garbe that you can find at https://github.com/leberwurstsaft/FontAwesome-for-iOS Version 2.0 of the Font Awesome font, CSS, and LESS files are licensed under CC BY 3.0: http://creativecommons.org/licenses/by/3.0/ A mention of 'Font Awesome - http://fortawesome.github.com/Font-Awesome' in human-readable source code is considered acceptable attribution (most common on the web). If human readable source code is not available to the end user, a mention in an 'About' or 'Credits' screen is considered acceptable (most common in desktop or mobile software)

Tuesday, 25 February 2014

View Controller Transitions iOS7


If you like to learn about animatedtransitioning this is the best blog that I have find, explains it very well: http://www.objc.io/issue-5/view-controller-transitions.html


View Controller Transitions
Issue #5 iOS 7, October 2013
By Chris Eidhof

One of the most exciting iOS 7 features for me is the new View Controller Transitioning API. Before iOS 7, I would also create custom transitions between view controllers, but doing this was not really supported, and a bit painful. Making those transitions interactive, however, was harder.

Before we continue with the article, I’d like to issue a warning: this is a very new API, and while we normally try to write about best practices, there are no clear best practices yet. It’ll probably take a few months, at least, to figure them out. This article is not so much a recommendation of best practices, but rather an exploration of a new feature. Please contact us if you find out better ways of using this API, so we can update this article.

Before we look at the API, note how the default behavior of navigation controllers in iOS 7 changed: the animation between two view controllers in a navigation controller looks slightly different, and it is interactive. For example, to pop a view controller, you can now pan from the left edge of the screen and interactively drag the current view controller to the right.

That said, let’s have a look at the API. What I found interesting is the heavy use of protocols and not concrete objects. While it felt a bit weird at first, I prefer this kind of API. It gives us as programmers much more flexibility. First, let’s try to do a very simple thing: having a custom animation when pushing a view controller in a navigation controller (the sample project for this article is on github). To do this, we have to implement one of the new UINavigationControllerDelegate methods:

- (id<UIViewControllerAnimatedTransitioning>)
                   navigationController:(UINavigationController *)navigationController
        animationControllerForOperation:(UINavigationControllerOperation)operation
                     fromViewController:(UIViewController*)fromVC
                       toViewController:(UIViewController*)toVC
{
    if (operation == UINavigationControllerOperationPush) {
        return self.animator;
    }
    return nil;
}

Read the rest of the article here : http://www.objc.io/issue-5/view-controller-transitions.html



Tuesday, 2 July 2013

Write Objective C code for absolute beginner (Quick Guide)

Objective C is basically object oriented C, its an extend C programming language. So, it has the basic syntax as C, are the primitive types, structures, functions, control flows (if, else, for, ...), pointers, and libraries.

What objective C adds to C ---> Defining new class, instance methods, methods invocations, automatic synthesizing of accessor methods, static and dynamic typing, blocks plus protocols and categories.

Lets start with classes and objects, a class encapsulates the data and defines actions to operate on that data and object is run time instance of the class.

Class extensions in objective C:
  • .h is the header file.
  • .m is the implementation file.
  • .mm is the implementation file if you are using C++ in your code as well.
 .h file:

@interface className : parentClassName

{
    // Member variables

}

 //method declarations

@end





.m file: 

// #import directive is like #include directive in C the difference is that #import directive makes sure // that the same header file never included more than once.

#import className.h

@implementation className
{
   

}

Objective C allows both static and dynamic typing:

className *object1;  // Static typing
id       object2;  // Dynamic typing
NSString *myName;  // static typing
 
 
Methods in objective C ----> Instance Methods and Class Methods
For instance method you need to create an instance of the class first then use the method. But Class Method dose not requires an instance of the class to be receiver of the message.

Instance method declaration is preceded by a minus sign (-). For Class Methods, its a plus sign (+).
 
written by: infinitywebseo 

Monday, 1 July 2013

What is autoreleasepool?

@autoreleasepool {

 return UIApplicationMain(argc, argv, nil, NSStringFromClass([yourAppNameAppDelegate class]));

}

Basically autoreleasepool supports automatic reference counting, which provides automatic object-life time management for your iOS application.

In simple words it just makes sure that objects are around as long as they are needed in your app and not longer.

written by: infinitywebseo