Skip to content

Instantly share code, notes, and snippets.

@swarut
Last active December 17, 2015 04:09
Show Gist options
  • Save swarut/5548246 to your computer and use it in GitHub Desktop.
Save swarut/5548246 to your computer and use it in GitHub Desktop.
aaaaaaaaa
- (void) navigateToSplitViewController{
[SVProgressHUD dismiss];
UIStoryboard *storyboard = self.storyboard;
IPadSplitViewHolder *splitView = [storyboard instantiateViewControllerWithIdentifier:@"IPadSplitViewHolder"];
//[self.navigationController pushViewController:splitView animated:YES];
//self.parentViewController.view.window.rootViewController = splitView;
self.view.window.rootViewController = splitView;
}
/* View interpolation */
for(UIView *aView in [self subviews]){
if([aView isKindOfClass:[UILabel class]]){
UILabel *label = ((UILabel*)aView);
[label setFont:[UIFactory getFontForKey:@"normal"]];
}
}
/* Image centralize crop */
NSString *ticketImage = [ticket absoluteImagePath:ticket.ticketImage];
self.image.contentMode = UIViewContentModeScaleAspectFill;
self.image.clipsToBounds = YES;
[self.image setImageWithURL:[NSURL URLWithString:ticketImage] placeholderImage:[UIImage imageNamed:@"ipad_placeholder_event_row.png"]];
/* Image circularize */
- (void) circularizeImage{
CALayer *imageLayer = [self.image layer];
[imageLayer setCornerRadius:60];
[imageLayer setBorderWidth:0];
[imageLayer setMasksToBounds:YES];
}
/* HTML display */
- (void)show:(NSString*)text{
NSString *messageHTML = [self HTMLStringFromText:text];
NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
[self.webView loadHTMLString:messageHTML baseURL:baseURL];
[self.webView setBackgroundColor:[UIColor clearColor]];
for (UIView* shadowView in [self.webView.scrollView subviews])
{
if ([shadowView isKindOfClass:[UIImageView class]]) {
[shadowView setHidden:YES];
}
}
}
- (NSString*) HTMLStringFromText:(NSString*)text{
NSMutableString *htmlOutput = [NSMutableString stringWithCapacity:2000];
[htmlOutput appendString:@"<html><head><link rel='stylesheet' type='text/css' href='base_ipad.css'>"];
[htmlOutput appendFormat:@"</head><body>"];
[htmlOutput appendFormat:@"<div class='container event_info'>"];
[htmlOutput appendString:text];
[htmlOutput appendFormat:@"</div>"];
[htmlOutput appendFormat:@"</body></html>"];
return htmlOutput;
}
/* Change textfield label color */
[textfield setValue:[UIFactory getFontColorForKey:@"place_holder"] forKeyPath:@"_placeholderLabel.textColor"];
/* Assign event handler */
[button addTarget:self action:@selector(hideKeyboard:) forControlEvents:UIControlEventTouchUpInside];
/* Show alert view */
alertView = [[UIAlertView alloc]initWithTitle:title message:message delegate:sender cancelButtonTitle:cancelButtonTitle otherButtonTitles:okayButtonTitle, retryButtonTitle, nil];
[alertView show];
/* Loading Plist */
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
NSString *resourcePath = nil;
if(language == kEnglish){
resourcePath = [bundlePath stringByAppendingPathComponent:@"application_en_texts.plist"];
}
else if (language == kThai){
resourcePath = [bundlePath stringByAppendingPathComponent:@"application_thai_texts.plist"];
}
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:resourcePath];
return dict;
/* Raise Exception */
[NSException raise:NSInternalInconsistencyException
format:@"You must override %@ in a subclass", NSStringFromSelector(_cmd)];
/* Prepare segue */
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:@"event_list_to_event"]){
IpadEventViewController* evc = [segue destinationViewController];
evc.eventID = ((EventRowView*)sender).eventID;
}
}
/* Get user default */
userDefaults = [NSUserDefaults standardUserDefaults];
/* Save user default */
[self.userDefaults setObject:token forKey:FBTOKEN];
[self.userDefaults synchronize];
/* Show/Hide Views */
- (void) hideViews{
for(UIView* view in [self.view subviews]){
view.hidden = YES;
}
[self.backgroundImage setHidden:NO];
}
- (void) showViews{
for(UIView* view in [self.view subviews]){
view.hidden = NO;
}
}
// Add title label
// Need to do it this way as we have to calculate the size of the title frame
CGRect labelFrame = CGRectMake(270,24, 380, 50);
FXLabel *title = [[FXLabel alloc] initWithFrame:labelFrame];
title.shadowOffset = CGSizeMake(1.0f, 1.0f);
title.shadowColor = [UIColor colorWithWhite:0.0f alpha:0.25f];
title.shadowBlur = 1.5f;
[title setBackgroundColor:[UIColor clearColor]];
NSString *labelText = event.eventTitle;
[title setText:labelText];
[title setFont:[UIFactory getFontForKey:@"event_row_title"]];
[title setNumberOfLines:0];
[title sizeToFit];
[self addSubview:title];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment