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
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray array]]; | |
[segmentedControl setMomentary:YES]; | |
[segmentedControl insertSegmentWithImage:[UIImage imageNamed:@"191-Up.png"] atIndex:0 animated:NO]; | |
[segmentedControl insertSegmentWithImage:[UIImage imageNamed:@"191-Down.png"] atIndex:1 animated:NO]; | |
segmentedControl.autoresizingMask = UIViewAutoresizingNone; | |
segmentedControl.frame = CGRectMake(0.0f, 0.0f, 90.0f, 30.0f); | |
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; | |
[segmentedControl addTarget:self action:@selector(pagingAction:) forControlEvents:UIControlEventValueChanged]; | |
UIBarButtonItem *segmentBarItem = [[UIBarButtonItem alloc] initWithCustomView:segmentedControl]; |
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
#define FONT_SIZE 14.0f | |
#define CELL_CONTENT_WIDTH 320.0f | |
#define CELL_CONTENT_MARGIN 10.0f | |
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath; | |
{ | |
NSString *text = [items objectAtIndex:[indexPath row]]; | |
CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 20000.0f); | |
CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap]; | |
CGFloat height = MAX(size.height, 44.0f); |
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
- (NSString *)getFirstImage:(NSString *)html { | |
NSString *tempText = [[NSString alloc]initWithFormat:@""]; | |
NSScanner *pageScanner = [NSScanner scannerWithString:html]; | |
[pageScanner setCaseSensitive:NO]; | |
[pageScanner setCharactersToBeSkipped:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; | |
[pageScanner scanUpToString:@"<img " intoString:nil]; | |
[pageScanner scanString:@"<img " intoString:nil]; | |
[pageScanner scanUpToString:@"src=\"" intoString:nil]; | |
[pageScanner scanString:@"src=\"" intoString:nil]; | |
[pageScanner scanUpToString:@"\"" intoString:&tempText]; |
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> | |
- (IBAction)tweetButtonTapped:(id)sender | |
{ | |
TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init]; | |
[twitter addURL:[NSURL URLWithString:@"http://www.sumardi.net"]; | |
[twitter setInitialText:@"Checkout my blog"]; | |
[self presentModalViewController:twitter 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
// Add <UIGestureRecognizerDelegate> in *.h file | |
- (void)viewDidLoad | |
{ | |
UITapGestureRecognizer *singleFingerDTap = [[UITapGestureRecognizer alloc] | |
initWithTarget:self action:@selector(handleDoubleTap:)]; | |
singleFingerDTap.numberOfTapsRequired = 2; | |
singleFingerDTap.delegate = self; | |
[self.webView addGestureRecognizer:singleFingerDTap]; | |
[singleFingerDTap release]; |
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
- (id)readPlist:(NSString *)fileName { | |
NSData *plistData; | |
NSString *error; | |
NSPropertyListFormat format; | |
id plist; | |
NSString *localizedPath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"plist"]; | |
plistData = [NSData dataWithContentsOfFile:localizedPath]; | |
plist = [NSPropertyListSerialization propertyListFromData:plistData mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&error]; |
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
#ifdef DEBUG | |
# define WMLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); | |
#else | |
# define WMLog(...) | |
#endif |
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
// .... | |
[self.view endEditing: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
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back" | |
style: UIBarButtonItemStyleBordered | |
target:nil | |
action:nil] autorelease];; |
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
.DS_Store | |
*.swp | |
*~.nib | |
build/ | |
*.pbxuser | |
*.perspective | |
*.perspectivev3 | |