Skip to content

Instantly share code, notes, and snippets.

Created March 6, 2012 09:34
Show Gist options
  • Select an option

  • Save anonymous/1985310 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/1985310 to your computer and use it in GitHub Desktop.
UIView
//
// NACommentsView.m
// NewspaperApp
//
// Created by MBP on 3/6/12.
// Copyright (c) 2012 Knowledgeview Ltd. All rights reserved.
//
#import "NACommentsView.h"
#import "NSBundle+Helpers.h"
#import "MBProgressHUD.h"
@implementation NACommentsView
@synthesize delegate;
@synthesize webView;
@synthesize urlString;
+(id) commentsView
{
return [[NSBundle mainBundle] loadObjectFromNibNamed:@"NACommentView" class:[self class] owner:nil options:nil];
}
#pragma mark - View
-(void)awakeFromNib
{
if (urlString != nil && [urlString length] > 0)
{
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.urlString]]];
}
}
//--------------------------
// Actions
//--------------------------
#pragma mark - Actions
- (IBAction)backAction:(id)sender
{
[delegate commentsViewDidSelectBackButton:self];
}
//--------------------------
//UIWebView Delegate Methode
//--------------------------
#pragma mark - UIWebViewDelegate
-(void)webViewDidStartLoad:(UIWebView *)webView
{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self animated:YES];
hud.labelText = @"Opening the Page";
}
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
[MBProgressHUD hideHUDForView:self animated:YES];
}
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
if ([self.delegate respondsToSelector:@selector(commentsView:DidFailWithError:)])
[delegate commentsView:self DidFailWithError:error];
}
//--------------------------
// Memory Management
//--------------------------
#pragma mark - Memory Management
- (void)dealloc {
[webView release];
[delegate release];
[urlString release];
[super dealloc];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment