Skip to content

Instantly share code, notes, and snippets.

@amleszk
amleszk / utableview reordering cells
Last active December 15, 2015 15:09
Example code to re-order all cells in a tableview
int toIndex=0;
[self.tableView beginUpdates];
for (NSDictionary* reddit in sortedReddits) {
NSString *displayName = [reddit valueForKeyPath:@"data.display_name"];
NSUInteger fromIndex =
[_reddits indexOfObjectPassingTest:^BOOL(NSDictionary *obj, NSUInteger idx, BOOL *stop) {
if ([[obj valueForKeyPath:@"data.display_name"] isEqualToString:displayName] ) {
*stop = YES;
return YES;
}
@amleszk
amleszk / gist:5225924
Created March 23, 2013 01:13
Hack to get around Facebook keyboard hiding, to keep compatibility for another hack to UIWindowLevel described here:(http://stackoverflow.com/questions/3753097/how-to-detect-touches-in-status-bar)
-(void) presentShareController:(SLComposeViewController*)shareCompose
{
if ([shareCompose.serviceType isEqualToString:SLServiceTypeFacebook]) {
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
UIWindowLevel prevWindowLevel = window.windowLevel;
window.windowLevel = UIWindowLevelNormal;
SLComposeViewControllerCompletionHandler handler = shareCompose.completionHandler;
shareCompose.completionHandler = ^(SLComposeViewControllerResult result){