Categories
Articles

Stop abusing App Delegate

Stop abusing App Delegate

Categories
Articles

VCRequestHandler

VCRequestHandler

Categories
Articles

Words that changed my life… Stay hungry, Stay foolish.

This is the text of the commencement address by Steve Jobs, CEO of Apple Computer and of Pixar Animation Studios, delivered on June 12, 2005.

I am honored to be with you today at your commencement from one of the finest universities in the world. I never graduated from college. Truth to be told, this is the closest I’ve ever gotten to college graduation. Today I want to tell you three stories of my life. That’s it. No big deal, just three stories.

The first story is about connecting the dots

I dropped out of Reed College after the first six months, but then stayed around as a drop-in for another 18 months or so before I really quit. So why did I drop out?

It started before I was born. My biological mother was young, unwed college graduate student, and she decided to put me up for adoption. She felt very strongly that I should be adopted by college graduates, so everything was all set for me to be adopted at birth by a lawyer and his wife. Except that when I popped out they decided that they wanted a girl. So my parents, who were on a waiting list, got a call in the middle of the night asking: “We have an unexpected baby boy; do you want him?” They said: “of course.” My biological mother later found that my mother had never graduated from college and that my father had never graduate from high school. She refused to sign the final adoption papers. She only relented few months later when my parents promised that I would someday go to college. And 17 years later I did go to college. But I naively chose a college that was almost as expensive as Stanford, and all of my working-class parents’ savings were being spent on my college tuitions. After six months, I couldn’t see the value in it. I had no idea what I wanted to do with my life and no idea how college was going to help me figure it out. And here I was spending all of the money my parents had saved their entire life. So I decided to drop out and trust that it would all work out OK. It was pretty scary that time, but looking back it was one of the best decisions I ever made. The minute I dropped out I could stop talking the required classes that didn’t interest me, and begin dropping in on the once that looked interesting. It wasn’t all romantic. I didn’t have a dorm room, so I slept on the floor in friend’s rooms, I returned coke bottle for 5€ deposits to buy food with, and I would walk the 7 miles across town every Sunday night to get one good meal a week at the hare Krishna temple. I loved it. And much of what I stumbled into by following my curiosity and intuition turned out to be priceless later on. Let me give you one example:

Reed College at that time offered perhaps the best calligraphy instruction in the country. Throughout the campus every poster, every label on every drawer, was beautifully hand calligraphed. Because I had dropped out and didn’t have to take the normal classes, I decided to take a calligraphy class to learn how to do this. I learned about serif and san serif typefaces, about varying the amount of space between different letter combinations, about what makes great typography great. It was beautiful, historical, artistically subtle in a way that science can’t capture, and I found it fascinating.

None of this had even a hope of any practical application in my life. But 10 years later, when we designing the first Macintosh computer, it all came back to me. And we designed it all into the Mac. It was the first computer with beautiful typography. If I had never dropped in on that single course in college, the Mac would have never had multiple typefaces and proportionally spaced fonts. And since windows just copied Mac, it’s likely that no personal computer would have them. If I had never dropped out, I would have never dropped in on this calligraphy class, and personal computer might not have the wonderful typography that they do. Of course it was impossible to connect the dots looking forward when I was in college. But it was very, very clear looking backwards 10 years later.

Again, you can’t connect the dots looking forward; you can only connect them looking backwards. So you have to trust that the dots will somehow connect in your future. You have to trust in something- your gut, destiny, life, karma, whatever. This approach has never let me down, and it has made all the difference in my life.

My second story is about love and loss

I was lucky-I found what I loved to do early in life. Woz and I started Apple in my parent’s garage when I was 20. We worked hard, and in 10 years Apple had grown from just two of us in garage into a $2 billion company with over 4,000 employees. We had just released our finest creation-the Macintosh-a year earlier, and I had just turned 30. And then I got fired. How can you get fired from company you started? Well, as Apple grew we hired someone who I thought was very talented to run company with me, and for the first year or so things went well. But then our vision of the future began to diverge and eventually we had falling out. When we did, our Board of Directors sided with him. So at 30 I was out. And very publicly out. What had been the focus of my entire adult life was gone, and it was devastating.

I really didn’t know what to do for a few months. I felt that I had let the previous generation of entrepreneurs down-that I had dropped the baton as it was being passed to me. I met with David Packard and Bob Noyce and tried to apologize for screwing up so badly. I was a very public failure, and I even thought about running away from the valley. But something slowly began to down on me-I still loved what I did. The turn of events at Apple had not changed that one bit. I had been rejected, but I was still in love. And I decided to start over.

I didn’t see it then, but it turned out that getting fired from Apple was the best thing that could have ever happened to me. The heaviness of being successful was replaced by the lightness of being a beginner again, less sure about everything. It freed me to enter one of the most creative periods of my life.

During the next 5 years, I started a company named NeXT, another company named Pixar, fell in love with an amazing woman who would become my wife. Pixar went on to create the world’s first computer animated feature film, Toy Story, and is now the most successful animation studio in the world. In a remarkable turn of events, Apple bought NeXT, I returned to Apple, and the technology we developed at NeXT is at the heart of Apple’s current renaissance. And Laurene and I have a wonderful family together.

I’m pretty sure none of this would have happened if I hadn’t been fired from Apple. It awful tasted medicine, but I guess the patient needed it. Sometimes life hits you in the head with a brick. Don’t lose faith. I’m convinced that the only thing that kept me going was that I loved what I did. You’ve got to find what you love. And that is true for your work as it is your lovers. Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven’t found it yet, keep looking. Don’t settle. As with all matters of the heart. You will know when you find it. And, like any great relationship, it just gets better and better as the years roll on. So keep looking until you find it. Don’t settle.

My third story is about death

When I was 17. I read a quote that went something like: “if you live each day as if it was your last, someday you’ll most certainly be right.” It made an impression on me, and since then, for the past 33 years. I have looked in the mirror every morning and asked myself: “if today were last day of my life, would I want to do what I am about to do today?” and whenever the answer has been “No” for too many days in a row. I know I need to change something.

Remembering that ill be dead soon is the most important tool I’ve ever encountered to help me make the big choices in life. Because almost everything all external expectations, all pride, all fear of embarrassment or failure-these things just fall away in the face of death, leaving only what is truly important. Remembering you are going to die is the best way I know to avoid the trap of thinking you have something to lose. You are already naked. There is no reason not to follow your heart.

About a year ago I was diagnosed with cancer. I had scan in the 7.30 in the morning. And it clearly showed a tumor on my pancreas. I didn’t even know what a pancreas was. The doctors told me this was almost certainly a type of cancer that is incurable, and I should expect to live no longer than three to six months. My doctor advised me to go home and get my affaires in order, which is doctor’s code for prepare to die. It means try to tell your kids everything you thought you’d have next 10 years to tell them in just a few months. It means to make sure everything is buttoned up so that it will be as easy as possible for your family. It means to say your goodbyes.

I lived with that diagnosis all day. Later that evening I had biopsy. Where they stuck an endoscope down my throat, through my stomach and into my intestine, put a needle into my pancreas and got few cells from the tumor. I was sedated, but my wife, who was there, told me that when they viewed cells under a microscope the doctor started crying because it turned out to be a very curable with surgery. I had the surgery and I’m fine now.

This was closest I’ve been to facing death, and I hope it’s the closest I get for few more decades. Having lived through it, I can now say this to you with a bit more certainly than when death was a useful but purely intellectual concept.

No one wants to die. Even people who want to go to heaven don’t want to die to get there. And yet death is the destination we all share. No one has ever escaped it. And that is as it should be, because Death is very likely the single best invention of life. It is life’s change agent. It clears out the old to make way for new. Right now the new is you, but someday not too long from now, you will gradually become old and be cleared away. Sorry to be so dramatic, but it is quite true.

Your time is limited, so don’t waste it living someone else’s life. Don’t be trapped by dogma-which is living with the results of other people’s thinking. Don’t let the noise of other’s opinions down out your own inner voice. And most important, have the courage to follow your heart and intuitions. They somehow already know what you truly want to become. Everything else is secondary.

When I was young, there was an amazing publication called The Whole Earth Catalog, which was one of the bibles of my generation. It was created by a fellow named Stevert Brand not far from here in Menlo Park, and brought it to life with his poetic touch. This was in the late 1960s, before personal computers and desktop publishing, so it was all made with typewriters, scissors, and Polaroid cameras. It was sort of like Google in paperback form, 35 years before Google came along: it was idealistic, and overwhelming with neat tools and great notions.

Stewart and his team put out several issues of The Whole Earth Catalog, and then when it had run its course, they put out final issue. It was the mid 1970s, and I was your age. On the back cover of their final issue was a photograph of an early morning country road, the kind you might find yourself hitchhiking on if you were so adventurous. Because it were the words: “Stay hungry, Stay foolish.” It was their farewell message as they signed off. And I have always wished that for myself. And now, as you graduate to begin anew, I wish that for you.

Stay hungry, Stay foolish.

Thank you all very much.

Thank you Steve.

Categories
Articles

Improve performance while using shadow/glow using layers

Whenever using layers to add shadow, add rounded corners, show border or anything, just remember to set “shouldRasterize” property of a layer object to YES, default value is NO.

self.layer.shouldRasterize = YES;

This is what header file says about “shouldRasterize” property.

When true, the layer is rendered as a bitmap in its local coordinate space (“rasterized”), then the bitmap is composited into the destination (with the minificationFilter and magnificationFilter properties of the layer applied if the bitmap needs scaling). Rasterization occurs after the layer’s filters and shadow effects are applied, but before the opacity modulation. As an implementation detail the rendering engine may attempt to cache and reuse the bitmap from one frame to the next. (Whether it does or not will have no affect on the rendered output.)

Categories
Articles

resourceURL equivalent before iOS 4

[[NSBundle mainBundle] resourceURL]

is same as

[NSURL fileURLWithPath:[[NSBundle mainBundle] resourcePath]]

I need to use it a lot while making local html pages to show in UIWebView. Just to remember. 🙂

Categories
Articles

Call iOS method for HTML button click

We can use custom urls for this purpose, Lets say we want to add a button1 into HTML page and we want to call “-didTapButton1” when user taps on button1.

We should have following code into HTML page that we are loading into UIWebView,

<a href="didTap://button1"><img src="button1.jpg" /></a>

Now next what we need to do is add methods from UIWebViewDelegate (To call this method the method owner needs to be the delegate for the UIWebView used),

- (BOOL)webView:(UIWebView*)aWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
    NSString *absoluteUrl = [[request URL] absoluteString];
    if ([absoluteUrl isEqualToString:@"didTap://button1"]) {
        [self didTapButton1];
        return NO;
    }
    return YES;
}

And it is done!!!

Categories
Articles

Why Service Providers should not get into retail app market

Gone are the days when individual developers or small companies used to make mobile apps, no one was really interested into mobile app system. And it all changed with iPhone App Store. People started thinking seriously about mobile apps as a business.

Still when iPhone App Store was just released very few developers and small companies were into the serious app making business. Small companies got good stardom, users and money making opportunity with it. Whats good about these indi developers and small organizations that they did not get stardom by selling apps, they got that stardom by selling those ideas that no other developers got or dared to implement. I remember when it had just started, apps like iBeer captured market very quickly and is still one of the most downloaded apps on mobiles. This lead to a huge wave of such mobile apps, but those were just replicas of what these guys implemented and copied apps just do not have that taste and originality. These few developers really did love what they did.

Now with that kind of tide in the mobile app market its not surprising that big shot service provider companies entered the platform, It wasn’t possible for these B-dudes to just ignore this kind of business opportunity. So most of the service based companies entered the field which was created by many indi developers with their creativity and love for the platform. Now this is where the problem lies.

Most Service Based Companies (SBC) Have No Taste

Service based companies provide services to the clients which actually wants to make mobile apps. Now these service based companies have brain for writing the code for the application. Clients have content to share. What about the taste and idea? SBCs have tight schedule for each app, so thinking out of the box is strictly prohibited at places like these and clients have no clue about standards and technical information required to make these apps. SBCs have designers, developers, they have all that needs to convert the app from “working app” to “gorgeous app”, but that conversion doesn’t really take place. Basically people who don’t know, want to make apps and people who know don’t really care about that.

It Doesn’t Help Developers Improve Skill Sets

Clients want their content to reach as many number of customers as it can. They do not care about the app, their primary concern is not the app but the content. So developers are forced to use older and outdated SDK version and support it.

eg. Still many SBCs keep the lowest deployment version as iOS 3.0, right now we have iOS 4.3.1 in the market.

As they are asked by client to do this ( clients too get scared of not reaching customers due to this), SBCs do not really have any say in this thing, or they don’t really care. So using new SDKs is again not advised because then the app would have the higher base version. This is not good for developers who work in these SBCs. They don’t really get to work on newest wonders added to the fresh versions of SDKs.

eg. NSRegularExpression from iOS 4.0 is not used, instead old third party code for regular expressions is added happily to the code (which btw has few potential leaks in the code).

No Happy Users and Harm to Platform

As a result of this, users like us don’t get to see apps which are truly amazing, which does more than just providing content, which makes users feel delightful. People want to see that added value into the apps, they want to see something new everyday(legitimate way), If they don’t see that extra thing into the apps for long time, Its the time when people start thinking about different platforms. This is really harmful for the whole platform.

People and developers working in these big shot companies should think about this. Apple WWDC contains very interesting session where presenter talks about how to go about app development, how to decide which app falls into which category, say Entertainment, Utility, Serious apps, this session also mentions the points that need to be consider while making different kind of applications. Consider that as a real challenge, making the app delightful while keeping it restricted to HIG provided.

Categories
Articles

Twitter should implement dialog based posting

I added this subject to the blog long time ago..some feb or something, I was gonna write a module that does the job but now…i dont think its required anymore ( this made me sad though :(, i didn get time to write that code ) since iOS5 has nice and beautiful tweet poster inbuilt into the OS. Its a delight!! ( Anyways i can write that code still! )

Categories
Articles

Read XML attributes in libxml SAX parser

Adding following lines in startElementSAXFunc method, and we can use attributes string keys and values as following.

for (int i = 0; i < nb_attributes; i++) {
    NSString *key = [[NSString alloc] initWithCString:(char*)attributes[0] 
                                             encoding:NSUTF8StringEncoding];
    NSString *value = [[NSString alloc] initWithCString:(char*)attributes[3] 
                                                 length:attributes[4] - attributes[3]]; 

    NSLog(@"%@ = %@", key, value);

    [key release];
    [value release];

    attributes += 5;
}
Categories
Articles

My latest work as a designer…

Categories
Articles

mundu IM Pro launched…

I was just too busy working on some cool iOS apps past few days. Adding some new UI tweaks, performance and other improvements to existing mundu IM Pro app.

And finally we have sent update to the apple, Should get approved in few days. ( mundu IM has never got rejected in the past. 🙂 )

http://twitter.com/#!/davinc/status/25094282717167616

For more info about “mundu IM Pro” on iPhone, please visit, http://itunes.apple.com/in/app/mundu-im-pro/id407228604?mt=8 or follow @munduIM

Follow @munduIM for free promo codes.

Categories
Articles

How to build an Apple Push Notification provider server (tutorial)

How to build an Apple Push Notification provider server (tutorial)

Categories
Articles

RSS Reader the way I need it…

Generally every person who is net freak starts his day by going through his RSS feeds. People like me, subscribe to many RSS feeds about programming, iPhone & Apple tech, Usability and stuff. Everyday I have about 30 unread articles in my reader app (I use NetNewsWire on mac). People start going through these articles and they really end up reading only small percentage of those unread, Usually only 5-6 out of 30. As most of the Articles are about same thing, same news, same product explored or smashed. Thats where the problem begins.

What people want to read at any given moment also depends on the external factors eg. Work place, Kitchen, Bedroom. When I am in Bedroom, I am really not interested in reading stuff about programming, similarly when I am at work place, I am not interested in reading and watching funny jokes and videos. There are many bloggers and site writing about the stuff from micro-gadgets to social and political views. This is the problem too.

The main goal and purpose of subscribing to RSS feeds is to stay connected and stay informed. People are really interested in reading the news or posts and not in the website posting that news. The news is more important, at least more important than the person or site who is posting it. Most of the RSS reader put RSS hosts at the primary position. They show how many unread posts are present on any given site. Of course some people are interested in sites and people who are posting the things as well, but the very definition of the RSS reader according to wiki says “It is a family of web feed formats used to publish frequently updated works—such as blog entries, news headlines, audio, and video—in a standardized format.” Here we can clearly see the important thing is entries and news. That is why I think most of the RSS reader apps are doing the things in pretty wrong way, they could do much better.

What most of the apps are doing right now is this…

image

What I am looking for in reader app is this…

image

I think Categories and Tags is what people actually need to see as a primary differentiator element. RSS feeds provide Categories in the XML that it sends so it could be done with some efforts. Maybe it will be great if user gets to decide what that user needs as a primary differentiator.

Categories
Articles

Saare Jahan Se Accha Tabs

On Our Republic Day…This is the only song that comes to my mind, really sounds too good on electric guitar.

Saare Jahan Se Accha

----------------------
4---------------------
---7--5-7---4--5--5---
----------------------
----------------------
----------------------

Hindostaan  Hamara...

-----------------------------
----------5-6-5-5---6-5------
-----5--7---------7-----7-5--
5--7-------------------------
-----------------------------
-----------------------------

Hum Bulbule Hai Isaki

-----------------5------
--6-8---8-8-5--6---8----
7-----------------------
------------------------
------------------------
------------------------

Yeh Gulsitan Hamara Hamara....

-------------------------------
5-6-8--6-----------------------
----------8--7-5-5--5-5-4------
--------------------------7-5--
-------------------------------
-------------------------------

Enjoy playing the tune…

Categories
Articles

NSDate and Sqlite3 in iPhone

While working with NSDate and sqlite3 on iPhone the common problem many people face is about storing and retrieving NSDate from sqlite3 database. There are mainly two methods to do so, one is to get the time interval (timeIntervalSince1970) from reference date and save the interval as double value in the database, second is to convert date into string using NSDateFormatter and save the text value in the database.

NOTE: The type of column where we want to store NSDate should be DATETIME in both the methods.

Method 1: using timeIntervalSince1970

Writing NSDate to sqlite3 DB

NSDate *dateToWrite = [NSDate date]; // current date
double valueToWrite = [date timeIntervalSince1970];
// save "valueToWrite" in DB as DOUBLE

Read NSDate from sqlite3 DB

//read double from sqlite3 DB n store it in valueFromDB(double)
NSDate *dateFromDB = [NSDate dateWithTimeIntervalSince1970:valueFromDB];

Method 2: using NSDateFormatter ( i prefer )

Writing NSDate to sqlite3 DB

NSDate *dateToWrite = [NSDate date]; // current date
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
NSString *stringToWrite = [dateFormatter stringFromDate:dateToWrite];
//save "stringToWrite" in DB as TEXT [dateFormatter release], dateFormatter = nil;

Reading NSDate from sqlite3 DB

//read TEXT from sqlite3 DB n store it in stringFromDB(NSString*)
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
NSDate *dateFromDB = [dateFormatter dateFromString:stringFromDB];
[dateFormatter release], dateFormatter = nil;

I personally prefer the 2nd method here though it takes more number of lines to do it. ( sometimes it’s better to write more number of lines )

While accessing database file from terminal we can easily read the stored date as it is very much humanly readable.

Happy Coding…

Categories
Articles

Kal Ho Naa Ho (tabs)

These are the tabs for one of my all time fav song. Tuned up my guitar and played it after real long time.

E-------------------10-8------------------ 2 times
B--11--10-11-10-11-------11-10--8-10-8-10-

E------6^------------------6^-------------
B--6-8----8----6-8~-6--6-8----8--9-8---6--
G------------8-----------------------8----

E-------------------10-8------------------ 2 times
B--11--10-11-10-11-------11-10--8-10-8-10-

E-------11-10-8---------------------11-10-8------------------
B-10-11---------11-10-10-11~---10-11---------11-10-10-11-86-

E------6^------------------6^-------------
B--6-8----8----6-8~-6--6-8----8--9-8---6--
G------------8-----------------------8----

Thanks and enjoy the song…. 🙂

Categories
Articles

How to enable emoji on iPhone (programatically)

Emoji is the Japanese term for the picture characters or emoticons used in Japanese wireless messages and webpages. Originally meaning pictograph, the word literally means e “picture” + moji “letter”. The characters are used much like emoticons elsewhere, but a wider range is provided, and the icons are standardized and built into the handsets. The three main Japanese operators, NTT DoCoMo, au and SoftBank Mobile (formerly Vodafone), have each defined their own variants of emoji.

image

Ok enough of this….Lets see how to enable this keyboard to be used everywhere. (By default this keyboard is only works on iPhones from Japan)

Step1:

- (void)enableEmoji {
#define kPreferencesFilePath @"/private/var/mobile/Library/Preferences/com.apple.Preferences.plist"
#define kEmojiKey @"KeyboardEmojiEverywhere"
    NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile:kPreferencesFilePath];
    if (!dict) return;
    // Toggle the setting from on to off or vice versa
    BOOL isSet = [[dict objectForKey:kEmojiKey] boolValue];
    if (!isSet) {
        [dict setObject:[NSNumber numberWithBool:YES] forKey:kEmojiKey];
        [dict writeToFile:kPreferencesFilePath atomically:NO];
    }
}

Note: This code does not work on iPhone Simulators, Works only on devices.

Step2: After running this code for once, go into “Settings” > “General” > “Keyboard” > “Japanese Keyboard”. Enable the “Emoji” keyboard.

Step3: Open any Notes.app & see the magic.

Note: According to Apple Forums its a private API, then how does applications on appStore are allowed to use it?

Categories
Articles

Flipping bar button like iTunes

This is the example for how to create flipping bar button like iTunes. I faced the same problem while developing solutions for first time, after looking at iTunes app more closely..it seems the flipping thing in Navigation Bar is not a BarButton but button with images ( It does not show highlighted effect ).

image

All we need to do is use custom UIBarButtonItem with CustomView for this.

Step 1: Create UIBarButton with CustomView

barButtonSuperView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 34, 30)];
barButtonPrimaryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 34, 30)];
UIButton * primaryButton = [UIButton buttonWithType:UIButtonTypeCustom];
primaryButton.frame = CGRectMake(0, 0, 34, 30);
[primaryButton setBackgroundColor:[UIColor greenColor]];
[primaryButton addTarget:self action:@selector(flipAction:) forControlEvents:UIControlEventTouchUpInside];
[barButtonPrimaryView addSubview:primaryButton];
 
barButtonSecondaryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 34, 30)];
UIButton * secondaryButton = [UIButton buttonWithType:UIButtonTypeCustom];
secondaryButton.frame = CGRectMake(0, 0, 34, 30);
[secondaryButton setBackgroundColor:[UIColor redColor]];
[secondaryButton addTarget:self action:@selector(flipAction:) forControlEvents:UIControlEventTouchUpInside];
[barButtonSecondaryView addSubview:secondaryButton];
 
// self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:barButtonSuperView] autorelease];
UIView * barButtonSuperSuperView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 34, 30)];
barButtonSuperSuperView.backgroundColor = [UIColor viewFlipsideBackgroundColor];
[barButtonSuperSuperView addSubview:barButtonSuperView];
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:barButtonSuperSuperView] autorelease];
[barButtonSuperSuperView release], barButtonSuperSuperView = nil;

Step 2: Use UIView transition effects

[UIView beginAnimations:@"BarButtonViewAnimation" context:NULL];
[UIView setAnimationDuration:kTransitionDuration];
[UIView setAnimationTransition:([barButtonPrimaryView superview] ?
    UIViewAnimationTransitionFlipFromLeft : UIViewAnimationTransitionFlipFromRight)
    forView:barButtonSuperView cache:YES];
 
if ([barButtonPrimaryView superview]) {
    [barButtonPrimaryView removeFromSuperview];
    [barButtonSuperView addSubview:barButtonSecondaryView];
} else {
    [barButtonPrimaryView removeFromSuperview];
    [barButtonSuperView addSubview:barButtonPrimaryView];

[UIView commitAnimations];

Here is the complete demo code.

Categories
Articles

UITableViewCell Selection

I have seen many many applications so far, i mean really awesome applications. Still one thing i see which is almost common with all of them except few one is that Custom UITableViewCells does not change text color when selected/highlighted. I am also a developer and i know these kind of things miss out while developing applications in rapid development cycles and under timeline pressure :(. but then it really shows high level of ignorance from developers side.

The solution is simple. Generally what we do is we create custom UIView and add it inside UITableViewCell. Just we need to do some extra coding in UIView. as shown in TableViewSuite.

CustomCellView.h

#import <UIKit/UIKit.h>

@interface CustomCellView : UIView {
    BOOL highlighted;
}

@property (nonatomic, getter=isHighlighted) BOOL highlighted;

@end

CustomCellView.m

#import "CustomCellView.h"

@implementation CustomCellView

@synthesize highlighted;

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        // Initialization code
    }
    return self;
}

- (void)setHighlighted:(BOOL)isHighlighted {
    // If highlighted state changes, need to redisplay.
    if (highlighted != isHighlighted) {
        highlighted = isHighlighted;
        [self setNeedsDisplay];
    }
}

- (void)drawRect:(CGRect)rect {
    UIColor *nameTextColor;
    if( self.highlighted ) {
        nameTextColor = [UIColor whiteColor];
    } else {
        nameTextColor = [UIColor blackColor];
    }
    // Draw code
}

- (void)dealloc {
    [super dealloc];
}

@end
Categories
Articles

Socha hai – Rock On tabs

I didn find good tabs for it anywhere so here i am posting my own version…

PART1
E--5----------------------------------------------------
B--7--------------------------3--------------2-3--------
G--7------4~----4-6-7---------2--0-2-4-----4-----2h4p2--
D--5--5-7-------------7h9p7~~---------------------------
A--5----------------------------------------------------
E--5----------------------------------------------------

PART2
E-------------------------------------
B---3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3---
G----2-2-2-2-0-0-0-0-4-4-4-4-2-2-2-2--
D-------------------------------------
A-------------------------------------
E-------------------------------------

PART1 & PART2 together 2 times

D
aasma hai neela kyun
Bm
paani geela geela kyun
G            A
gol kyun hai zamee
D
silk mein hai narmi kyun
Bm
aag mein hai garmi kyun
G                A
do aur do paanch kyun nahi
.. and so on