Thursday, October 31, 2013

Xcode 5 third party libs, frameworks Linker Error

Hi There,

I am currently working on a project which was developed by someone else.
When I cloned the project for the first time, I was getting linker errors for the third party libs, frameworks like FacebookSDK.framework, flurry etc.
Thought I could see these libs were there in the project navigator and also in the Finder, I really couldn't understand why it was showing the linker errors.
I did few things like Cleaning the project, restarting Xcode, restarting even the mac, which didn't at all work.
Finally found the solution, which I really couldn't thought about and I should have thought about.
Just remove the libs and then re-add them again. (Face-palm).
I know, this should be the obvious first try. Anyway.

Happy Coding.



Thursday, October 24, 2013

Making Vodafone K3800 dongle on Mac OSx Mavericks

Hey,
I just updated the MacBook Pro to OSx Mavericks.
i use Vodafone K3800 stick.
Before the update the dongle was working fine, but after the update of course, it stopped working.
I thought I need to update the Vodafone Mobile Broadband (VMB) software, then it should work.
But unfortunately, it was not that straight forward.
I went to Vodafone support web site and downloaded and installed all the possible versions of VMB from 4.0.7 to 4.0.9. (of course restarted the mac many times).
I was assuming, installing one of these should do. But nothing worked.

But after trial and error, got a way to make it work.

1. Install VMB 4.0.9.17, which is supposed to be the latest version.
2. Install Vodafone K3800 software, which is there in the stick itself.
That's it.
Then the Vodafone K3800 stick will work properly.

Both the softwares need to be installed. Only one of them will never work.

Happy Surfing.





Monday, October 21, 2013

In UITextView subclass for iOS 7, UITextView contentSize.Height returns wrong value

Hello,

When the UITextView is subclassed, contentSize.height works very well in iOS 6 downwards, but in iOS 7 it fails and returns the value which is far less than the actual value.

Here is the fix.

Replace the float height=textView.contentSize.height by

float height=[self measureHeight];

-(void) measureHeight
{
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
    if ([self respondsToSelector:@selector(snapshotViewAfterScreenUpdates:)])
    {
        CGRect frame = internalTextView.bounds;
        CGSize fudgeFactor;
        // The padding added around the text on iOS6 and iOS7 is different.
        fudgeFactor = CGSizeMake(10.0, 16.0);
        
        frame.size.height -= fudgeFactor.height;
        frame.size.width -= fudgeFactor.width;
        
        NSMutableAttributedString* textToMeasure;
        if(internalTextView.attributedText && internalTextView.attributedText.length > 0){
            textToMeasure = [[NSMutableAttributedString alloc] initWithAttributedString:internalTextView.attributedText];
        }
        else{
            textToMeasure = [[NSMutableAttributedString alloc] initWithString:internalTextView.text];
            [textToMeasure addAttribute:NSFontAttributeName value:internalTextView.font range:NSMakeRange(0, textToMeasure.length)];
        }
        
        if ([textToMeasure.string hasSuffix:@"\n"])
        {
            [textToMeasure appendAttributedString:[[NSAttributedString alloc] initWithString:@"-" attributes:@{NSFontAttributeName: internalTextView.font}]];
        }
        
        // NSAttributedString class method: boundingRectWithSize:options:context is
        // available only on ios7.0 sdk.
        CGRect size = [textToMeasure boundingRectWithSize:CGSizeMake(CGRectGetWidth(frame), MAXFLOAT)
                                                  options:NSStringDrawingUsesLineFragmentOrigin
                                                  context:nil];
        
        return CGRectGetHeight(size) + fudgeFactor.height;
    }
    else
    {
        return self.internalTextView.contentSize.height;
    }
#else
    return self.internalTextView.contentSize.height;
#endif

}

This should work.