Showing posts with label iPhone. Show all posts
Showing posts with label iPhone. Show all posts

Jun 16, 2014

Format NSString to left pad zeroes in Objective C

Posted Jun 16, 2014
01, 02, 03, 04, 05..
int num = 1;
[NSString stringWithFormat:@"%02d", num];

001, 002, 003, 004, 005..
[NSString stringWithFormat:@"%03d", num];

0001, 0002, 0003, 0004, 0005..
[NSString stringWithFormat:@"%04d", num];

You get the pattern? Good!


May 12, 2014

Anywhere Pad, the Board Portal Software for iPads and Android Tablets

Posted May 12, 2014

Around a year ago, I wrote about Anywhere Pad, particularly about its new design. That blog entry was more of a test than anything else, but I thought of doing a follow-up post because a lot has happened since I published the first one.

Yes, I'm still affiliated with the product, but I can say with only a tiny hint of bias that Anywhere Pad has significantly improved from the first time I featured it here. 

Aside from the continuous enhancements we've been adding to refine Anywhere Pad's usability, we also made it more streamlined by aligning the Android version with the iOS version. Our goal is to give directors and administrators the same user experience whether they're using an iPad or Android tablet. It's not enough that Anywhere Pad works on Android and iOS. We want it to work just as well for either platform so whatever you choose, you get to enjoy all the benefits and conveniences offered by Anywhere Pad.

This move is in response to the fact that many organizations are now adopting a Bring Your Own Device (BYOD) policy. We realize the policy won't be effective unless people have the freedom to choose whatever device to use; but with most board portal vendors offering board portal solutions for iPad use only, administrators and directors have no choice but to switch to iOS tablets if they aren't already using one yet. Don't get me wrong – iPads are great gadgets. But there are a lot of folks who prefer to use Android devices (which are great gadgets, too) so it only makes sense that they get choice in the matter as well.

Thus, we made Anywhere Pad a viable Android board portal solution for enterprise use. With stringent security features such as AES-256 network encryption, AES-128 document encryption, 2048-bit SSL, ISO 27001 (AWS EC2), on-the-fly decryption, automatic purge for lost devices, audit logging, and fine-grained access control, Anywhere Pad can effectively safeguard confidential information from malicious attacks and unauthorized access, whether the threat is internal or external.

Aside from security, we also beefed up the real-paper feel directors have been looking for in a board portal solution. The freehand annotation feature allows users to write comments using their own hand or stylus, while the whiteboard lets them draw diagrams (and even doodles) and map out processes.

To learn more about Anywhere Pad and its capabilities, request for a demo or quote.


Sep 17, 2013

[Solved] Smooth Div Scrolling in iPad Browser (or iPhone / iOS Devices)

Posted Sep 17, 2013
If you have a scrollable div using overflow: auto or overflow: scroll, you will notice that the scroll is slow or choppy. To make the inline scroll smooth, just add the following in your css class:

-webkit-overflow-scrolling: touch;

E.g.

#SCROLLABLE_DIV {
  height: 300px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

Jan 10, 2013

[Solved] Property 'cornerRadius' cannot be found in forward class object 'CALayer *'

Posted Jan 10, 2013
When I tried the following:

UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectZero];
myLabel.layer.cornerRadius = 2.0f;
[myLabel release];

I get an error: Property 'cornerRadius' cannot be found in forward class object 'CALayer *'

The solution is to import the QuartzCore framework:

#import <QuartzCore/QuartzCore.h>

Happy coding!

Jan 8, 2013

Get GMT in iOS using NSTimezone

Posted Jan 8, 2013
There are cases that you want to get the GMT string of an iPhone / iPad device. Here's how you can do it:

  NSTimeZone *localTime = [NSTimeZone systemTimeZone];
  CGFloat gmt = ([localTime secondsFromGMT]/60.f/60.f);
  
  NSMutableString *gmtStr = [[[NSMutableString alloc] init] autorelease];
  int hours;
  if (gmt < 0) {
    hours = ceil(gmt);
  } else {
    hours = floor(gmt);
  }
  
  int minutes = abs(round((gmt - hours) * 60));
  
  if (gmt >= 0) {
    [gmtStr appendFormat:@"+%d",hours];
  } else {
    [gmtStr appendFormat:@"%d",hours];
  }
  
  if (minutes > 0) {
    [gmtStr appendFormat:@":%02d", minutes];
  }
  
  NSLog(@"GMT is %@", gmtStr);

Jan 4, 2013

UIView is blurred after setting its width (autoresizingmask / anchoring related)

Posted Jan 4, 2013
Blurring of views usually occurs when the device is trying to fit 1 point to two pixels. This happens when you have an x or y origin with a decimal place. X or Y origins can have unintentional decimal places when you're setting the "center" property of the view instead of the actual frame. It is more apparent in non-retina devices because they have fewer pixels.

Unintentional decimal places in a view's origin can also occur when you set the width of a view that has an autoresizingmask where the view is automatically anchored to its parent and the system is adjusting the origin for you.

In my experience, I get a blurred view in landscape mode when my I set the width of my anchored view to an odd number, so I just make sure I always set the width to an even number.
E.g.

CGRect myRect = self.view.frame;
int myRectInt = (int) roundf(myRect.size.width);
if (myRectInt % 2 != 0) {
  myRect.size.width = myRectInt + 1;
}
self.view.frame = myRect;

Happy coding!

Converting CGFloat to int [Objective-C]

There are cases that you want to convert float numbers to integer. One example is when you're using a frame's attribute, say, frame.size.width and you want to know if it's odd or even number. Before you can do a modulo operation, the numbers must be in integer format.

The easiest way is to round the float value first and typecast it to int.
E.g.


int integerWidth = (int) roundf(myFrame.size.width);

Hope this helps!

Jun 21, 2012

Use Anywhere Pad to Conduct Meetings on your iPad, iPhone and Android devices

Posted Jun 21, 2012
Anywhere Pad is an e-meeting app for iPad and iPhone. It's a cool app and it's free, and yes I'm affiliated with Azeus. This is more of a TEST than a promotion.

Anywhere Pad is a lot of things: Document collaboration on your mobile device, meeting application, document management, scheduling, annotations, etc. It also won the Best Ubiquitous Networking Award (Mobile Enterpries Solution) in Hong Kong.

Anyway, I just want to see the Google ranking of this post.

We showed some love for Android, so it's coming to this platform too. It's now available on Android and Window platform.

So what else can I write in this entry to boost ranking..  hmm it's Enterprise grade, secure, you can draw your annotations and highlight words. You can host the meeting using your local network (through WiFi) or through internet using Azeus portal server. Meet with people, use it for board meetings, collaborate with a colleague, etc.

Tested on iPad 1, iPad 2, iPad 3 (New iPad), iPhone 4, iPhone 4s. Okay, don't know what else to say. Just download it and try. I wonder if this page will make it on the first page of Google results.

And to give my biased rating: 4.5

May 29, 2012

MS Word to PDF displays boxes when viewed in iOS (iPhone / iPad)

Posted May 29, 2012
If the text in your PDF displays boxes when viewed iPad or iPhone, one of the cause might be the conversion of MS Word to PDF.

Try these simple steps to see if it resolves the issue:
  1. Open MS Word
  2. File -> Save As
  3. Select PDF type
  4. Click Options
  5. ISO 19005-1 compliant (PDF/A) should be ticked.
  6. Try to save the document to PDF and view it in your iPhone / iPad.


I'm using MS Word 2010 and Windows 7.  PDF is properly displayed in desktop and Android devices, but in iOS (UIWebView, Safari, etc), the text is just a series of black boxes; like it's been highlighted with a black marker. The fix above solves the issue.

May 24, 2012

Singleton Pattern in Objective-C (iOS) and release method (oneway) issue

Posted May 24, 2012
Apple gives a good sample on how to create a singleton class; I've modified it a bit for iOS programming:

static MyGizmoClass *sharedInstance = nil;

+ (MyGizmoClass*) sharedInstance
{
    if (sharedInstance == nil) {
        sharedInstance = [[super allocWithZone:NULL] init];
    }
    return sharedInstance;
}

+ (id)allocWithZone:(NSZone *)zone
{
    return [[self sharedInstance] retain];
}

- (id)copyWithZone:(NSZone *)zone
{
    return self;
}

- (id)retain
{
    return self;
}

- (NSUInteger)retainCount
{
    return NSUIntegerMax;  //denotes an object that cannot be released
}

- (oneway void)release
{
    //do nothing
}

- (id)autorelease
{
    return self;
}


Modifications:
  1. Used "sharedInstance" method and variable name to make it easier to copy paste.
  2. - (void) release to - (oneway void) release
    The singleton sample produces a warning in the release method because NSObject uses the "oneway" return type modifier. It's basically an indication that the method is used for asynchronous messages. For more details on what oneway does, toodarkpark.net offers a good explanation.

Jul 20, 2011

How to make UILabel's text bold

Posted Jul 20, 2011
If you want to retain the system font and make it bold:

[myLabel setFont:[UIFont boldSystemFontOfSize:16]];