Escape code for % sign in NSString

The escape code for a percent sign is “%%”, so your code would look like this

[NSString stringWithFormat:@”%d%%”, someDigit];

This is also true for NSLog() and printf() formats.

Cited from http://stackoverflow.com/questions/739682/how-to-add-percent-sign-to-nsstring.

Blogged with the Flock Browser

How to show button popover on iPad

CGRect contentRect = CGRectMake(0, 0, 200, 40);
UIButton *source = [UIButton buttonWithType:UIButtonTypeCustom];
source.frame = contentRect;

source.titleLabel.text = @”Delete”;

source.backgroundColor = [UIColor redColor];

UIViewController* popoverContent = [[UIViewController alloc] init];
popoverContent.view = source;

popoverContent.contentSizeForViewInPopover = contentRect.size;

UIPopoverController *popoverController = [[UIPopoverController alloc] initWithContentViewController:popoverContent];

[popoverController presentPopoverFromRect:[sender frame]
inView:window
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];

[popoverContent release];

Blogged with the Flock Browser

Tags: , ,