вторник, 24 июля 2012 г.

How to delete a row in UITableView manually?

To delete row from table manually (programmatically) at first remove items from array with table items, which you use to build table cells. Then you should use method

[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
Where instead of
[NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:0]]
you should use your array with index paths. Here just first row will be removed.
And don't forget to wrap this method into
[self.tableView beginUpdates];
...
[self.tableView endUpdates];
So in conclusion this code should looks like this

понедельник, 23 июля 2012 г.

Change frame size for modal controller with modalPresentationStyle = UIModalPresentationFormSheet

ARC version
ModalViewController *targetController = [[ModalViewController alloc] init];
targetController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:targetController animated:YES];
targetController.view.superview.frame = CGRectMake(0, 0, 200, 200);//it's important to do this after presentModalViewController
targetController.view.superview.center = self.view.center;//self.view assumes the base view is doing the launching, if not you might need self.view.superview.center etc.
None ARC
ModalViewController *targetController = [[[ModalViewController alloc] init] autorelease];
targetController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:targetController animated:YES];
targetController.view.superview.frame = CGRectMake(0, 0, 200, 200);//it's important to do this after presentModalViewController
targetController.view.superview.center = self.view.center;//self.view assumes the base view is doing the launching, if not you might need self.view.superview.center etc.
see on stackoverflow.com

четверг, 19 июля 2012 г.

How to switch UIsegmentedControll programmatically

// select the first segment
segmented.selectedSegmentIndex = 0;

// turn off the current selection
segmented.selectedSegmentIndex = UISegmentedControlNoSegment;

вторник, 17 июля 2012 г.

How to force update git

git fetch --all 
git reset --hard origin/master
Git fetch downloads the latest from remote without trying to merge or rebase anything. 
Then the git reset resets the master branch to what you just fetched.