Category Archives: iOS / Objective-C

Problems with BadgeValue text color when overwrites UILabel

If you overwrite the UILabel in Objective C, for example to get the functionality of VerticalAlign, like I wanted to do, You can get bad side effects.

I used a small code part I found on Internet, to get this functions.

@implementation UILabel (VerticalAlign)
- (void)alignTop {
    CGSize fontSize = [self.text sizeWithFont:self.font];
    double finalHeight = fontSize.height * self.numberOfLines;
    double finalWidth = self.frame.size.width;    //expected width of label
    CGSize theStringSize = [self.text sizeWithFont:self.font  constrainedToSize:CGSizeMake(finalWidth, finalHeight) lineBreakMode:self.lineBreakMode];
    int newLinesToPad = (finalHeight  - theStringSize.height) / fontSize.height;
    for(int i=0; i<newLinesToPad; i++)
        self.text = [self.text stringByAppendingString:@"\n "];
}
 
- (void)alignBottom {
    CGSize fontSize = [self.text sizeWithFont:self.font];
    double finalHeight = fontSize.height * self.numberOfLines;
    double finalWidth = self.frame.size.width;    //expected width of label
    CGSize theStringSize = [self.text sizeWithFont:self.font constrainedToSize:CGSizeMake(finalWidth, finalHeight) lineBreakMode:self.lineBreakMode];
    int newLinesToPad = (finalHeight  - theStringSize.height) / fontSize.height;
    for(int i=0; i<newLinesToPad; i++)
        self.text = [NSString stringWithFormat:@" \n%@",self.text];
}
 
- (void)awakeFromNib {
    [super awakeFromNib];
    [self setFont:[UIFont fontWithName:@"KievitPro-Regular" size:12.0]];
}
 
-(id)initWithFrame:(CGRect)frame {
    id result = [super initWithFrame:frame];
    if (result) {
        [self setFont:[UIFont fontWithName:@"KievitPro-Regular" size:12.0]];
    }
    return result;
}
 
@end
Continue reading “Problems with BadgeValue text color when overwrites UILabel” »

Print Friendly

Remove / Add (Hide) UITabbarItems on the fly

Some days ago, I searched for a solution to hide a TabbarItem from my app but select it programmatically. In all forums and blogs was written, that this is not possible. Hiding a TabbarItem means to remove it from the Tabbar or, on other places, hiding means to disable it, but a disabled Item is still visible only not selectable.

What to do now? Is there an intermediate solution? Yes, it is, somehow: Continue reading “Remove / Add (Hide) UITabbarItems on the fly” »

Print Friendly

Include Facebook “Post to your wall” in your App

I’m somhow a newbee in developing iPhone-Apps. This means a lot of searching in iNet, try-and-error and “throwning the mac out of the window”…

My task was to implement social networks in my app.
Twitter: 15 minutes
Mail: 2 hours
Facebook: 8 days (!!)

The examples from facebook, which are delivered with their framework, are somehow really good, but they do to much things for me. I only wanted to post to the users wall, nothing more. So I took the code from their samples, include them in my app -> DAMN, nothing works anymore. Continue reading “Include Facebook “Post to your wall” in your App” »

Print Friendly