Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
iOS Development
uiwebview problem
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="sagarshivam" data-source="post: 1295188" data-attributes="member: 203583"><p>Left panel is 3 level deep and each level is uitabletype. So on tapping row of first table, second table is pushed and similarly on tapping cell of second table , third table is pushed (which contains a list of files located on local server, ex: tp://172.22.79.169/~spp/Cref.pdf (outdated link removed).These files are absolutely accessible)</p><p></p><p>Till the time, third table is pushed, detail view shows activity indicator and it keeps on moving. It works fine.</p><p></p><p>Now , on tapping third table's cell, webview should be loaded in detail view and corresponding tapped file (variable detailItem is every time assigned with the URL of file) should be loaded in uiwebview. And the problem is that uiwebview is not getting loaded and file is not viewed and finally activity indicator keeps on moving.</p><p></p><p>I am sure that the problem is related to uiwebview and I am not using IB to make either of interface.</p><p></p><p>Codes are :</p><p></p><p>for last level table (I am not posting code for other tables as everything related to them are proper functioning.), code is:</p><p></p><p>SubTable.h</p><p></p><p>[CODE]</p><p>#import <UIKit/UIKit.h></p><p>@class DetailViewController;</p><p>@interface SubTable : UITableViewController {</p><p> NSArray *file_list_for_subproject;</p><p> DetailViewController *detailViewController;</p><p> </p><p>}</p><p></p><p>@property (nonatomic, retain) NSArray *file_list_for_subproject;</p><p>@property (nonatomic,retain) DetailViewController *detailViewController;</p><p>@end</p><p>[/CODE]</p><p></p><p>SubTable.m</p><p></p><p>[CODE]</p><p>#import "SubTable.h"</p><p>#import "DetailViewController.h"</p><p>#import "SecondLevelViewController.h"</p><p></p><p>@implementation SubTable</p><p></p><p>@synthesize file_list_for_subproject,detailViewController;</p><p>- (void)viewDidLoad {</p><p> [super viewDidLoad];</p><p> detailViewController = [[DetailViewController alloc] init];</p><p> self.clearsSelectionOnViewWillAppear = NO;</p><p> self.navigationItem.rightBarButtonItem = self.editButtonItem;</p><p> }</p><p></p><p>-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {</p><p> return YES;</p><p>}</p><p></p><p></p><p>- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {</p><p> return 1;</p><p>}</p><p></p><p></p><p>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {</p><p> </p><p> return [file_list_for_subproject count];</p><p>}</p><p></p><p>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {</p><p>NSInteger row = [indexPath row];</p><p> UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"any-cell"];</p><p> UILabel *labelView = NULL;</p><p> if (cell == nil) {</p><p> </p><p> cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"any-cell"] autorelease];</p><p> cell.selectionStyle = UITableViewCellSelectionStyleGray;</p><p> [[[cell subviews] objectAtIndex:0] setTag:111];</p><p> labelView = [[UILabel alloc] initWithFrame: CGRectMake(8, 0, 300, 44)];</p><p> [labelView setBackgroundColor:[UIColor clearColor]];</p><p> [labelView setTag:222];</p><p> [labelView setFont:[UIFont boldSystemFontOfSize:20]];</p><p> [cell addSubview:labelView];</p><p> [labelView release];</p><p> UIView *cellView = [cell viewWithTag:111];</p><p> if (row % 2)</p><p> [cellView setBackgroundColor:[UIColor whiteColor]];</p><p> else</p><p> [cellView setBackgroundColor:[UIColor colorWithRed:0.90f green:0.95f blue:1.0f alpha:1.0f]];</p><p> </p><p> [(UILabel *)[cell viewWithTag:222] setText:[file_list_for_subproject objectAtIndex:indexPath.row]];</p><p> </p><p> } </p><p> return cell;</p><p>}</p><p></p><p>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {</p><p> detailViewController.detailItem = [file_list_for_subproject objectAtIndex:indexPath.row];</p><p> </p><p>} </p><p>/* variable detailitem in DetailViewController class is assigned file url every time any cell is tapped here. And I have checked using NSLog that detailItem is containing that url. Everything works fine till here</p><p>*/</p><p>[/CODE]</p><p></p><p>DetailViewController.h is:</p><p>[CODE]</p><p>#import <UIKit/UIKit.h></p><p></p><p>@interface DetailViewController : UIViewController <UIPopoverControllerDelegate, UISplitViewControllerDelegate,UIWebViewDelegate> {</p><p> </p><p> UIPopoverController *popoverController;</p><p> UIToolbar *toolbar;</p><p> UIWebView *webview;</p><p> id detailItem;</p><p> UILabel *detailDescriptionLabel;</p><p> UIActivityIndicatorView *uiact;</p><p> </p><p>}</p><p></p><p>@property (nonatomic, retain) IBOutlet UIToolbar *toolbar;</p><p></p><p>@property (nonatomic, retain) id detailItem;</p><p>@property (nonatomic, retain) IBOutlet UILabel *detailDescriptionLabel;</p><p>@property (nonatomic,retain) UIWebView *webview;</p><p>@property (nonatomic ,retain) UIActivityIndicatorView *uiact;</p><p>@end</p><p>[/CODE]</p><p></p><p>DetailViewController.m is:</p><p></p><p>[CODE]</p><p>#import "DetailViewController.h"</p><p></p><p>@interface DetailViewController ()</p><p>@property (nonatomic, retain) UIPopoverController *popoverController;</p><p>@end</p><p></p><p>@implementation DetailViewController</p><p></p><p>@synthesize toolbar, popoverController, detailItem, detailDescriptionLabel,webview,uiact;</p><p></p><p>- (void)setDetailItem:(id)newDetailItem {</p><p> if (detailItem != newDetailItem) {</p><p> [detailItem release];</p><p> detailItem = [newDetailItem retain]; //detailItem contains url of file </p><p> // tapped in table</p><p> [self performSelector:@selector(startWebViewLoad) withObject:nil afterDelay:0];</p><p> }</p><p> </p><p> if (popoverController != nil) {</p><p> [popoverController dismissPopoverAnimated:YES];</p><p> } </p><p>}</p><p></p><p>- (void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc {</p><p> </p><p> barButtonItem.title = @"Root List";</p><p> NSMutableArray *items = [[toolbar items] mutableCopy];</p><p> [items insertObject:barButtonItem atIndex:0];</p><p> [toolbar setItems:items animated:YES];</p><p> [items release];</p><p> self.popoverController = pc;</p><p>}</p><p></p><p>- (void)splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {</p><p> </p><p> NSMutableArray *items = [[toolbar items] mutableCopy];</p><p> [items removeObjectAtIndex:0];</p><p> [toolbar setItems:items animated:YES];</p><p> [items release];</p><p> self.popoverController = nil;</p><p>}</p><p></p><p></p><p>- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {</p><p> return YES;</p><p>}</p><p></p><p>- (void)startWebViewLoad {</p><p> NSLog(@"detail item is ------ %@", detailItem); // It is displaying</p><p> // correct file URL</p><p> CGRect frame= [[UIScreen mainScreen] applicationFrame];</p><p> UIWebView *webview1 = [[UIWebView alloc] initWithFrame:frame];</p><p> webview1.backgroundColor = [UIColor redColor]; // I cant see red</p><p> //color in detail view</p><p> webview1.scalesPageToFit =YES;</p><p> self.webview =webview1;</p><p> NSString *file_path=detailItem;</p><p> NSURL *urlpath = [NSURL URLWithString:file_path];</p><p> NSURLRequest *reqobj = [NSURLRequest requestWithURL:urlpath];</p><p> [self.webview loadRequest:reqobj];</p><p> [self.view addSubview: self.webview];</p><p> [webview1 release];</p><p> //there is no UIWebView getting loaded, I guess and activityindicator keeps on moving</p><p>}</p><p></p><p></p><p>- (void)viewDidLoad{</p><p> </p><p> UIActivityIndicatorView *progressWheel = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(260,260,90,90)];</p><p> progressWheel.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;</p><p> progressWheel.hidesWhenStopped = YES;</p><p> self.uiact = progressWheel;</p><p> [self.view addSubview: self.uiact];</p><p> [self.uiact startAnimating];</p><p> [progressWheel release]; </p><p> </p><p>}</p><p></p><p>// Activityindicator should start right from Root table view, and its working well as expected</p><p>[/CODE]</p><p></p><p></p><p>I want to know where am I making mistake? And why file is not getting diplayed in uiwebview in detailview. Files are completely accessible and they are well displayed when using in different project.</p></blockquote><p></p>
[QUOTE="sagarshivam, post: 1295188, member: 203583"] Left panel is 3 level deep and each level is uitabletype. So on tapping row of first table, second table is pushed and similarly on tapping cell of second table , third table is pushed (which contains a list of files located on local server, ex: tp://172.22.79.169/~spp/Cref.pdf (outdated link removed).These files are absolutely accessible) Till the time, third table is pushed, detail view shows activity indicator and it keeps on moving. It works fine. Now , on tapping third table's cell, webview should be loaded in detail view and corresponding tapped file (variable detailItem is every time assigned with the URL of file) should be loaded in uiwebview. And the problem is that uiwebview is not getting loaded and file is not viewed and finally activity indicator keeps on moving. I am sure that the problem is related to uiwebview and I am not using IB to make either of interface. Codes are : for last level table (I am not posting code for other tables as everything related to them are proper functioning.), code is: SubTable.h [CODE] #import <UIKit/UIKit.h> @class DetailViewController; @interface SubTable : UITableViewController { NSArray *file_list_for_subproject; DetailViewController *detailViewController; } @property (nonatomic, retain) NSArray *file_list_for_subproject; @property (nonatomic,retain) DetailViewController *detailViewController; @end [/CODE] SubTable.m [CODE] #import "SubTable.h" #import "DetailViewController.h" #import "SecondLevelViewController.h" @implementation SubTable @synthesize file_list_for_subproject,detailViewController; - (void)viewDidLoad { [super viewDidLoad]; detailViewController = [[DetailViewController alloc] init]; self.clearsSelectionOnViewWillAppear = NO; self.navigationItem.rightBarButtonItem = self.editButtonItem; } -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [file_list_for_subproject count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSInteger row = [indexPath row]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"any-cell"]; UILabel *labelView = NULL; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"any-cell"] autorelease]; cell.selectionStyle = UITableViewCellSelectionStyleGray; [[[cell subviews] objectAtIndex:0] setTag:111]; labelView = [[UILabel alloc] initWithFrame: CGRectMake(8, 0, 300, 44)]; [labelView setBackgroundColor:[UIColor clearColor]]; [labelView setTag:222]; [labelView setFont:[UIFont boldSystemFontOfSize:20]]; [cell addSubview:labelView]; [labelView release]; UIView *cellView = [cell viewWithTag:111]; if (row % 2) [cellView setBackgroundColor:[UIColor whiteColor]]; else [cellView setBackgroundColor:[UIColor colorWithRed:0.90f green:0.95f blue:1.0f alpha:1.0f]]; [(UILabel *)[cell viewWithTag:222] setText:[file_list_for_subproject objectAtIndex:indexPath.row]]; } return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { detailViewController.detailItem = [file_list_for_subproject objectAtIndex:indexPath.row]; } /* variable detailitem in DetailViewController class is assigned file url every time any cell is tapped here. And I have checked using NSLog that detailItem is containing that url. Everything works fine till here */ [/CODE] DetailViewController.h is: [CODE] #import <UIKit/UIKit.h> @interface DetailViewController : UIViewController <UIPopoverControllerDelegate, UISplitViewControllerDelegate,UIWebViewDelegate> { UIPopoverController *popoverController; UIToolbar *toolbar; UIWebView *webview; id detailItem; UILabel *detailDescriptionLabel; UIActivityIndicatorView *uiact; } @property (nonatomic, retain) IBOutlet UIToolbar *toolbar; @property (nonatomic, retain) id detailItem; @property (nonatomic, retain) IBOutlet UILabel *detailDescriptionLabel; @property (nonatomic,retain) UIWebView *webview; @property (nonatomic ,retain) UIActivityIndicatorView *uiact; @end [/CODE] DetailViewController.m is: [CODE] #import "DetailViewController.h" @interface DetailViewController () @property (nonatomic, retain) UIPopoverController *popoverController; @end @implementation DetailViewController @synthesize toolbar, popoverController, detailItem, detailDescriptionLabel,webview,uiact; - (void)setDetailItem:(id)newDetailItem { if (detailItem != newDetailItem) { [detailItem release]; detailItem = [newDetailItem retain]; //detailItem contains url of file // tapped in table [self performSelector:@selector(startWebViewLoad) withObject:nil afterDelay:0]; } if (popoverController != nil) { [popoverController dismissPopoverAnimated:YES]; } } - (void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc { barButtonItem.title = @"Root List"; NSMutableArray *items = [[toolbar items] mutableCopy]; [items insertObject:barButtonItem atIndex:0]; [toolbar setItems:items animated:YES]; [items release]; self.popoverController = pc; } - (void)splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem { NSMutableArray *items = [[toolbar items] mutableCopy]; [items removeObjectAtIndex:0]; [toolbar setItems:items animated:YES]; [items release]; self.popoverController = nil; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } - (void)startWebViewLoad { NSLog(@"detail item is ------ %@", detailItem); // It is displaying // correct file URL CGRect frame= [[UIScreen mainScreen] applicationFrame]; UIWebView *webview1 = [[UIWebView alloc] initWithFrame:frame]; webview1.backgroundColor = [UIColor redColor]; // I cant see red //color in detail view webview1.scalesPageToFit =YES; self.webview =webview1; NSString *file_path=detailItem; NSURL *urlpath = [NSURL URLWithString:file_path]; NSURLRequest *reqobj = [NSURLRequest requestWithURL:urlpath]; [self.webview loadRequest:reqobj]; [self.view addSubview: self.webview]; [webview1 release]; //there is no UIWebView getting loaded, I guess and activityindicator keeps on moving } - (void)viewDidLoad{ UIActivityIndicatorView *progressWheel = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(260,260,90,90)]; progressWheel.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; progressWheel.hidesWhenStopped = YES; self.uiact = progressWheel; [self.view addSubview: self.uiact]; [self.uiact startAnimating]; [progressWheel release]; } // Activityindicator should start right from Root table view, and its working well as expected [/CODE] I want to know where am I making mistake? And why file is not getting diplayed in uiwebview in detailview. Files are completely accessible and they are well displayed when using in different project. [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
iOS Development
uiwebview problem
Top