Skip to content

Instantly share code, notes, and snippets.

@Qiki
Qiki / gist:c41fea71170648c5a8ae
Created May 24, 2014 19:08
Remove spell check text field
[self.emailAddressField setAutocorrectionType:UITextAutocorrectionTypeNo];
@Qiki
Qiki / gist:3f86f1f0c99f2320fbbd
Created September 8, 2014 14:09
Different between NSInteger and NSNumber
NSInteger is a type definition that describes an integer - but it is NOT equivalent to int on 64-bit platforms.
NSInteger is defined as int when building a 32-bit app and as long for 64-bit apps.
NSNumber is a class that helps you to store numeric types as object. It has methods to convert between different types and methods to retrieve a string representation of your numeric value.
If you use a variable day of type NSNumber* the way you did in your example, you are not modifying the value of day but its memory address.
@Qiki
Qiki / gist:33f7f306da89e32f32d5
Created September 8, 2014 14:11
NSUserDefaults
NSUserDefaults - need to call the synchronize every time you saved the data
it isn’t gauranteed it’ll be saved immediately. sometimes it’ll wait XX seconds to do a synchronize on its own but by then the app could crash or the user could close the app
@Qiki
Qiki / gist:bfa560ace78dc573ede2
Created November 3, 2014 20:06
Shipment Status
'C' => 'Shipped',
'C_NC' => 'In your NOOK Library',
'D' => 'Your order cannot be processed. Please contact customer service',
'F' => 'Your order cannot be processed. Please contact customer service',
'N' => 'Processing',
'O' => 'Processing',
'P' => 'Your order cannot be processed. Please contact customer service',
'V' => 'Processing',
'X' => 'Canceled',
@Qiki
Qiki / Using segue in ViewController
Last active December 26, 2015 09:29
Using Segue in ViewController
//call the segue to put the data you want to transfer
- (IBAction)click{
[self performSegueWithIdentifier:@"PUSH_NEXT"
sender:[NSDictionary dictionaryWithObjectsAndKeys:
self.page.data,@"data",nil]];
}
//prepareForSegue - tranfer the data to next viewController and push to the next view controller
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"PUSH_NEXT"]) {
NextPageViewController *vc = [segue destinationViewController]; //set destination view controller
@Qiki
Qiki / imageScrollView
Created October 27, 2013 19:24
Showing various images in a scroll view
self.scrollView.pagingEnabled = YES; // making the image can scroll one by one
+ for(NSInteger i = 0; i < self.imageURL.count;i++){ //doing several loop to add the image on the scroll view
+
+ CGFloat xOrigin = i * self.view.frame.size.width;
+ UIImageView *awesomeView = [[UIImageView alloc] initWithFrame:CGRectMake(xOrigin, 0, self.view.frame.size.width, self.view.frame.size.height-90)];
+ [awesomeView setImageWithURL:self.imageURL[i][@"2x"]];
+ [self.scrollView addSubview:awesomeView];
+ }
+
+ [self.scrollView setContentOffset:CGPointMake([self.tag integerValue] * self.view.frame.size.width, 0) animated:NO];//set offset-- which means the first image show- basing on the width and do calculation
@Qiki
Qiki / gist:6ff662ab35fb07e2914a
Created February 19, 2016 17:33
UINavigationController initWithRootViewController
So there is tricky thing (it will happen sometimes)
/*
* When set a storyboardID in a viewcontroller, and you want to show the navigation item
* you need to init NavigationController with rootviewcontoller
*/
UIViewControllers *niceVC = [shop instantiateViewControllerWithIdentifier:@"nice"];
UINavigationController *niceNav = [[UINavigationController alloc] initWithRootViewController:nice];
----------------------------------------
cell.textLabel.text = [NSString stringWithFormat:@" %@", @"indent"];
- (void)aboutSizeOfHeaderview {
// In order to show the label in the header view, we need to make the header view has a situable height
CGFloat padding = 8.0;
CGRect boundingRect = [self.wishListHeaderLabel.text boundingRectWithSize:CGSizeMake(self.view.bounds.size.width - (padding * 2), CGFLOAT_MAX) options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading) attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15.0f]} context:nil];
UIView *header = self.tableView.tableHeaderView;
CGRect rect = CGRectMake(0, 0, self.view.bounds.size.width,
boundingRect.size.height + 10.0f);
header.frame = rect;
self.tableView.tableHeaderView = header;
(function(XHR) {
var send = XHR.prototype.send;
XHR.prototype.send = function(data) {
var self = this;
function onReadyStateChange() {
if(self.readyState == 4 ) {
windows.location = 'ajaxHandler://' + self.url;
}
}