To change a delete button title use this:
1 2 3 4 5 6 7 |
- (NSString *)tableView:(UITableView *)tableView \ titleForDeleteConfirmationButtonForRowAtIndexPath: \ (NSIndexPath *)indexPath { return @"Удалить из избранного"; } |
To change a background color of a grouped table view in iOS we need to do two things:
1 2 |
self.tableView.backgroundColor = your_color; self.tableView.backgroundView = nil; |
It is the third answer here.
I will explain, how to create an animation, when you Default image comes to front with dissolving.
To create an animated Intro View in iOS App, which has a TabBarController you may do the following:
1 2 3 4 5 6 |
IntroViewController *introViewController = \ [[IntroViewController alloc] initWithNibName: \ @"IntroViewController" bundle:nil]; self.window.rootViewController = introViewController; [self.window makeKeyAndVisible]; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [UIView animateWithDuration:0.5 animations:^{ CGRect frame = self.imageView.frame; frame.origin.x -= frame.size.width; frame.origin.y -= frame.size.height; frame.size.width *= 3; frame.size.height *= 3; self.imageView.frame = frame; self.imageView.alpha = 0.0; } completion:^(BOOL finished){ useDelegate appDelegate.window.rootViewController = \ appDelegate.tabBarController; } ]; } |
Explanation:
After app loads, Intro View Controller is diplayed. Then, when it’s view appears, it’s UIImageView’s frame is trippled in size and it’s origin is moved to top left. Also the transparency is changed to 100%. After animation finishes, your tab bar controller is displayed.
Opening file:
1 |
$ vim ~/.bash_profile |
File contents:
1 2 3 4 5 6 7 8 9 |
PS1='\w: $ ' git='/Users/user/Documents/SourceCode/FromGITHub' profile='/Users/user/.bash_profile' sim='/Users/user/Library/Application Support/ iPhone Simulator/5.1/Applications' desktop='/Users/user/Desktop/' docs='/Users/user/Documents/' dl='/Users/user/Downloads/' mclient='/Users/user/Documents/mail/' |
Activation:
1 |
$ source ~/.bash_profile |
Usage:
1 2 |
$ cd "$mclient" $ cd "$sim" |
1. Open terminal
2. Write something like this according to your project:
1 |
~/Documents/mail: $ grep -lr "three20" * |
3. You will see all files, that contain three20 string.
4. The main thing to make your project compile and start working is to delete three20 entries from project.xcworkspace file, that can be found in finder by right clicking your project file and selecting show package contents. Open this file in any editor(I use Fraise) and using find delete all entries. It is not hard to do this, I had about 3-4 entries there only.
5. Other user interface state files also may contain three20 entries, but they are not important.
6. Also you should delete anything else concerning three20 (files, folders, header search paths, etc.). It’s more simple.
This is an example of sorting an array of custom objects by date in Objective C in descending order. Sorting by date is not different from sorting by NSInteger.
There are two ways to do this. First is to use NSSortDescriptor:
1 2 3 4 5 6 |
NSSortDescriptor *sortDescriptor = \ [[NSSortDescriptor alloc] initWithKey:@"dateTime" \ ascending:NO]; messagesArray = [messagesArray \ sortedArrayUsingDescriptors:[NSArray \ arrayWithObject:sortDescriptor]]; |
The second is to use NSComparisonResult:
1 2 3 4 5 6 7 8 |
NSArray *sortedArray; sortedArray = [array sortedArrayUsingComparator: \ ^NSComparisonResult(id a, id b) { NSDate *first = [(MCMessage*)a dateTime]; NSDate *second = [(MCMessage*)b dateTime]; return [second compare:first]; }]; array = sortedArray; |
To sort in ascending order change this line:
1 2 3 |
return [second compare:first]; return [first compare:second]; |
This post helped me a lot.
To make buttons the same color, as Apple’s default buttons on navigation bar, use the following:
1 2 |
button.tintColor = [UIColor colorWithHue:0.6\ saturation:0.33 brightness:0.69 alpha:0]; |
I found this answer here.
Sometimes Git doesn’t work properly with .DS_Store files in each of the folders.
This is how to git remove all .DS_Store files recursively:
1 |
find . -name .DS_Store -exec git rm {} + |
Here dot after “find” means that it will search in all folders inside current folder.
“-exec” runs “git rm” for each found file.
Plus means the end of the “-exec” statement.
This is how you programmatically add a button like UIBarButtonItem to the center of Navigation Bar:
1 2 3 4 5 6 7 8 9 10 11 12 |
UISegmentedControl *button = [[UISegmentedControl alloc]\\ initWithItems:[NSArray arrayWithObjects:\\ LS(@"Folders"), nil]]; button.frame = CGRectMake(0, 0, 100, 30); button.center = self.view.center; button.momentary = YES; button.segmentedControlStyle = UISegmentedControlStyleBar; button.tintColor = UIColorFromRGB(0x0000DD); [button addTarget:self action:\\ @selector(foldersClicked) forControlEvents:\\ UIControlEventValueChanged]; self.navigationItem.titleView = button; |