This file contains hidden or 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
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset | |
{ | |
UITableView *tableView = (UITableView *)scrollView; | |
int n = tableView.frame.size.height / _cellHeight; | |
if ((int)tableView.frame.size.height % (int)_cellHeight) n++; | |
for (int i = 0; i <= n; i++) { | |
NSIndexPath *indexPath = [tableView indexPathForRowAtPoint:CGPointMake(0, targetContentOffset->y + i * _cellHeight)]; |
This file contains hidden or 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
- (BOOL)isModal | |
{ | |
return (self == [self.navigationController.viewControllers objectAtIndex:0]); | |
} |
This file contains hidden or 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
UITextPosition *newPos = [textField positionFromPosition:textField.beginningOfDocument offset:0]; | |
textField.selectedTextRange = [textField textRangeFromPosition:newPos toPosition:newPos]; | |
[textField setNeedsLayout]; |
This file contains hidden or 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
NSMutableOrderedSet *set = [NSMutableOrderedSet orderedSetWithArray:array1]; | |
[set addObjectsFromArray:array2]; | |
array3 = [set sortedArrayUsingComparator:^(NSString *obj1, NSString *obj2) { | |
return [obj1 compare:obj2]; | |
}]; |
This file contains hidden or 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
// 現在のviewControllerを閉じてanotherViewControllerに差し替える | |
NSMutableArray *viewControllers = [NSMutableArray arrayWithArray:self.navigationController.viewControllers]; | |
[viewControllers removeLastObject]; | |
[viewControllers addObject:anotherViewController]; | |
[self.navigationController setViewControllers:viewControllers animated:YES]; |
This file contains hidden or 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
//------------------------------------------------------------------------- | |
// MSBlocks.h | |
//------------------------------------------------------------------------- | |
@interface MSBlocks : NSObject | |
+ (NSArray *)array:(NSArray *)array select:(BOOL(^)(id))block; | |
+ (id)find:(NSArray *)array match:(BOOL(^)(id))block; | |
@end | |
//------------------------------------------------------------------------- | |
// MSBlocks.m |
This file contains hidden or 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
# カレントディレクトリ以下のファイルは644, ディレクトリは755に統一 | |
# (パーミッションを削る方向で) | |
find . -type f -print0 | xargs -0 chmod go-wx | |
find . -type f -print0 | xargs -0 chmod u-x | |
find . -type d -print0 | xargs -0 chmod go-w |
This file contains hidden or 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
-- 2行目でタイトル、本文、ノートブックを指定してください | |
tell application "Evernote" | |
set note1 to create note title "Hello World!" with text "" notebook "TestNotebook" | |
set tag1 to tag "SmartEver" | |
assign tag1 to note1 | |
open note window with note1 | |
end tell |
This file contains hidden or 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
#import <Twitter/Twitter.h> | |
#import <Social/Social.h> | |
// TWTweetComposeViewControllerの場合 (for iOS5) | |
- (IBAction)tweet:(id)sender | |
{ | |
if ([TWTweetComposeViewController canSendTweet]) { | |
// ツイート用の画面をを表示する | |
TWTweetComposeViewController* composeViewController = [[TWTweetComposeViewController alloc] init]; | |
[composeViewController setInitialText:@"Hello World!"]; |
This file contains hidden or 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
CGFloat margin = 3.0; | |
CGFloat w = aView.bounds.size.width; | |
CGFloat h = aView.bounds.size.height; | |
CALayer *borderLayer = [CALayer layer]; | |
borderLayer.borderColor = [UIColor lightGrayColor].CGColor; | |
borderLayer.borderWidth = 1; | |
borderLayer.frame = CGRectMake(-margin, -margin, w + margin * 2, h + margin * 2); | |
[aView.layer addSublayer:borderLayer]; |
OlderNewer