Skip to content

Commit

Permalink
now that SVModalWebViewController exists, we can cleanup some old code
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverLetterer committed Aug 13, 2011
1 parent b80d03f commit 1f01273
Showing 1 changed file with 11 additions and 66 deletions.
77 changes: 11 additions & 66 deletions SVWebViewController/SVWebViewController.m
Expand Up @@ -42,11 +42,8 @@ - (id)initWithURL:(NSURL *)aURL {
}

- (void)viewDidLoad {

[super viewDidLoad];

CGRect deviceBounds = [[UIApplication sharedApplication] keyWindow].bounds;

if(!deviceIsTablet) {

backBarButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"SVWebViewController.bundle/iPhone/back"] style:UIBarButtonItemStylePlain target:self.webView action:@selector(goBack)];
Expand All @@ -59,61 +56,20 @@ - (void)viewDidLoad {

actionBarButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(showActions)];

if(self.navigationController == nil) {

navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0,0,CGRectGetWidth(deviceBounds),44)];
navBar.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleBottomMargin;
[self.view addSubview:navBar];
[navBar release];

navItem = [[UINavigationItem alloc] initWithTitle:self.title];
[navBar setItems:[NSArray arrayWithObject:navItem] animated:YES];
[navItem release];

toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.view.bounds)-44, CGRectGetWidth(deviceBounds), 44)];
toolbar.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleWidth;
[self.view addSubview:toolbar];
[toolbar release];
}

else {
navBar = self.navigationController.navigationBar;
toolbar = self.navigationController.toolbar;
}
navBar = self.navigationController.navigationBar;
toolbar = self.navigationController.toolbar;
}

else {

if(self.navigationController == nil) {

navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0,0,CGRectGetWidth(deviceBounds),44)];
navBar.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleBottomMargin;
[self.view addSubview:navBar];
[navBar release];

UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissController)];

navItem = [[UINavigationItem alloc] initWithTitle:nil];
navItem.leftBarButtonItem = doneButton;
[doneButton release];

[navBar setItems:[NSArray arrayWithObject:navItem] animated:YES];
[navItem release];

titleLeftOffset = [@"Done" sizeWithFont:[UIFont boldSystemFontOfSize:12]].width+33;
}

else {
self.hidesBottomBarWhenPushed = YES;
self.title = nil;

navBar = self.navigationController.navigationBar;
navBar.autoresizesSubviews = YES;

NSArray* viewCtrlers = self.navigationController.viewControllers;
UIViewController* prevCtrler = [viewCtrlers objectAtIndex:[viewCtrlers count]-2];
titleLeftOffset = [prevCtrler.navigationItem.backBarButtonItem.title sizeWithFont:[UIFont boldSystemFontOfSize:12]].width+26;
}
self.hidesBottomBarWhenPushed = YES;
self.title = nil;

navBar = self.navigationController.navigationBar;
navBar.autoresizesSubviews = YES;

NSArray* viewCtrlers = self.navigationController.viewControllers;
UIViewController* prevCtrler = [viewCtrlers objectAtIndex:[viewCtrlers count]-2];
titleLeftOffset = [prevCtrler.navigationItem.backBarButtonItem.title sizeWithFont:[UIFont boldSystemFontOfSize:12]].width+26;

backButton = [UIButton buttonWithType:UIButtonTypeCustom];
[backButton setBackgroundImage:[UIImage imageNamed:@"SVWebViewController.bundle/iPad/back"] forState:UIControlStateNormal];
Expand Down Expand Up @@ -260,12 +216,6 @@ - (void)layoutSubviews {


- (void)setupToolbar {

if(!navItem.leftBarButtonItem) {
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissController)];
[navItem setLeftBarButtonItem:doneButton animated:YES];
[doneButton release];
}

if(self.navigationController != nil)
self.navigationItem.title = [self.webView stringByEvaluatingJavaScriptFromString:@"document.title"];
Expand Down Expand Up @@ -437,11 +387,6 @@ - (void)showActions {
[actionSheet release];
}


- (void)dismissController {
[self dismissModalViewControllerAnimated:YES];
}

#pragma mark -
#pragma mark UIActionSheetDelegate

Expand Down

0 comments on commit 1f01273

Please sign in to comment.