How to place UIBarButtonItem on the right side of a UIToolbar?

Here’s how to do it in code if anyone comes across this post: UIBarButtonItem *leftButton = [[[UIBarButtonItem alloc] initWithTitle:@”Item” style:UIBarButtonItemStyleBordered target:self action:@selector(btnItem1Pressed:)] autorelease]; UIBarButtonItem *flex = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil] autorelease]; UIBarButtonItem *rightButton = [[[UIBarButtonItem alloc] initWithTitle:@”Item” style:UIBarButtonItemStyleBordered target:self action:@selector(btnItem2Pressed:)] autorelease]; self.toolbarItems = [NSArray arrayWithObjects: leftButton, flex, rightButton, nil];

Great UIKit/Objective-C code snippets

Open an URL in Safari [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@”http://www.google.com/”]]; Hide the status bar [[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO]; Dial a Phone Number (iPhone Only) [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@”tel://9662256888″]]; Launch the Apple Mail [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@”mailto://mymail@myserver.com”]]; stop responding to touch events [[UIApplication sharedApplication] beginIgnoringInteractionEvents]; active the touch events [[UIApplication sharedApplication] endIgnoringInteractionEvents]; Show the network Activity Indicator … Read more

Center UIPickerView Text

– (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 37)]; label.text = [NSString stringWithFormat:@”something here”]; label.textAlignment = NSTextAlignmentCenter; //Changed to NS as UI is deprecated. label.backgroundColor = [UIColor clearColor]; [label autorelease]; return label; } or something like this.

Can font size of UILabel be changed with smooth animation on iPhone?

Set the font on the UILabel to be the size that you want when it is enlarged. Then scale it down. When you want the label to swell, scale it back up to it’s original size. messageLabel.font = [UIFont boldSystemFontOfSize:45]; messageLabel.transform = CGAffineTransformScale(messageLabel.transform, 0.25, 0.25); [self.view addSubview:messageLabel]; [UIView animateWithDuration:1.0 animations:^{ messageLabel.transform = CGAffineTransformScale(messageLabel.transform, 4, 4); … Read more

Deactivate UIScrollView decelerating

This can be done by utilizing the UIScrollView delegate method scrollViewWillBeginDecelerating to automatically set the content offset to the current screen position. To implement: Assign a delegate to your UIScrollView object if you have not already done so. In your delegate’s .m implementation file, add the following lines of code: -(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{ [scrollView setContentOffset:scrollView.contentOffset animated:YES]; … Read more

tech