This file contains 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
#pragma mark - UITableView Datasource | |
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ | |
return 1; | |
} | |
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ | |
return 5; | |
} | |
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ | |
static NSString *CellIdentifier = @"ClubCell"; | |
ClubCell *cell = (ClubCell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
This file contains 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
1) Open terminal | |
2) $ sudo gem install cocoapods (gem will get installed in Ruby inside System library) | |
3)pod setup | |
4) create a xcode project | |
5) cd "$ path to your project root directory" (cd /Volumes/...) | |
6) pod init | |
7) open -a Xcode Podfile (podfile will get open in text mode. Initially it will be emppty put the follwoing line of code.) | |
8) pod 'AFNetworking', '0.9.1' (It’s finally time to add your first dependency using CocoaPods! Copy and paste the following into your pod file, right after target "AFNetworkingProject" do:) | |
9) pod install | |
Make sure you run “$ pod install” command every time you add or delete a new library to the Podfile. |
This file contains 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
//GET | |
+(void) checkLoginWithUsername:(NSString*)username andPassword:(NSString*)password InBackground:(void(^)(BOOL success)) completionHandler{ | |
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; | |
NSDictionary *para = [NSDictionary dictionaryWithObjectsAndKeys:username, @"email", password, @"password", nil]; | |
[manager setRequestSerializer:[AFHTTPRequestSerializer serializer]]; | |
[manager.requestSerializer setAuthorizationHeaderFieldWithUsername:@"admin" password:@"admin"]; | |
manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"]; | |
[manager GET:@"http://lottofy.gleblu.com/ws/login.php" parameters:para success:^(AFHTTPRequestOperation *operation, id responseObject) { | |
if ([[responseObject objectForKey:@"success"] doubleValue] == 0) { | |
completionHandler(NO); |
This file contains 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
// Call ViewController with UINavigationController | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
// Override point for customization after application launch. | |
MainVC *vcMain = [[MainVC alloc] initWithNibName:@"MainVC" bundle:nil]; | |
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vcMain]; | |
self.window.rootViewController = nav; | |
nav.navigationBarHidden = YES; | |
return YES; |
This file contains 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
// BASIC | |
MBProgressHUD *hud; | |
hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; | |
hud.mode = MBProgressHUDModeIndeterminate; | |
hud.labelText = @"loading..."; | |
[hud show:YES]; | |
--> [hud hide:YES]; |
This file contains 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
#pragma mark - Process data | |
- (CGFloat) calculateWidthItem{ | |
return ([[UIScreen mainScreen]bounds].size.width -16 - 4*10)/2; | |
} | |
- (CGFloat) calculateHeightItem{ | |
return (([[UIScreen mainScreen]bounds].size.width -16 - 4*10)/2)*1.5; | |
} | |
--> widthItem = [self calculateWidthItem]; | |
heightItem = [self calculateHeightItem]; |
This file contains 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
// SINGLETON PATTERN | |
-->.h: | |
+ (instancetype)sharedInstance; | |
-->.m: | |
+ (instancetype)sharedInstance | |
{ | |
static MyClass *sharedInstance = nil; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
sharedInstance = [[MyClass alloc] init]; |
This file contains 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
// Width constraint, half of parent view width | |
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:centerView | |
attribute:NSLayoutAttributeWidth | |
relatedBy:NSLayoutRelationEqual | |
toItem:self.view | |
attribute:NSLayoutAttributeWidth | |
multiplier:0.5 | |
constant:0]]; | |
// Height constraint, half of parent view height |
This file contains 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
//ViewDidLoad | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(keyboardWillShow:) | |
name:UIKeyboardWillShowNotification | |
object:nil]; | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(keyboardWillHide:) | |
name:UIKeyboardWillHideNotification | |
object:nil]; | |
This file contains 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 <UIKit/UIKit.h> | |
@interface MyTextField : UITextField | |
{ | |
BOOL isEnablePadding; | |
float paddingLeft; | |
float paddingRight; | |
float paddingTop; | |
float paddingBottom; | |
} |
OlderNewer