This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Resize a UIButton according to its title's length. | |
CGSize stringSize = [self.myButton.titleLabel.text sizeWithFont:self.myButton.titleLabel.font]; | |
CGRect frame = self.myButton.frame; | |
frame.size.width = stringSize.width; | |
[self.myButton setFrame:frame]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Displaying a right bar info button item | |
UIButton *btn = [UIButton buttonWithType:UIButtonTypeInfoDark]; | |
[btn addTarget:self action:@selector(doSomeAction:) forControlEvents:UIControlEventTouchUpInside]; | |
UIBarButtonItem *bbi = [[UIBarButtonItem alloc] initWithCustomView:btn]; | |
self.navigationItem.rightBarButtonItem = bbi; | |
[bbi release]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Display a right bar Close button item | |
UIBarButtonItem *bbi = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleBordered target:self action:@selector(doClose:)]; | |
self.navigationItem.rightBarButtonItem = bbi; | |
[bbi release]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Horizontal flip transition of a modal view | |
MyViewController *av = [[[MyViewController alloc] init] autorelease]; | |
[av setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal]; | |
[av setModalPresentationStyle:UIModalPresentationCurrentContext]; | |
[self presentModalViewController:av animated:YES]; | |
[av release]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SomeViewController.m | |
// | |
- (IBAction)doShowSomething:(id)sender | |
{ | |
UINavigationController *nav = [[[UINavigationController alloc]init] autorelease]; | |
MyViewController *av = [[[MyViewController alloc] init] autorelease]; | |
[nav pushViewController:av animated:NO]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dispatch_async(dispatch_get_main_queue(), ^{ | |
/* your code */ | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cell.selectedBackgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; | |
cell.selectedBackgroundView.backgroundColor = <your color>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cell.textLabel.highlightedTextColor = <your color>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example for UIControlStateNormal | |
[yourbutton setTitleColor:<your color> forState:UIControlStateNormal]; | |
// Example for UIControlStateHighlighted | |
[yourbutton setTitleColor:<your color> forState:UIControlStateHighlighted]; | |
// And so on... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Trimming white spaces and new line characters from a NSString | |
NSString *s = @" hellow world. "; | |
NSString *trimmedString= [s stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]]; |
OlderNewer