0

I am trying to show a webview on top of the uitableview, I designed the view in Nib, but I am doing something seriously wrong and it does not work at all..

In the uitableview controller I do this;

modalWebView *webUIViewController = [[modalWebView  alloc] init];
NSArray* s=[[NSBundle mainBundle] loadNibNamed:@"modalWebView" owner:webUIViewController options:nil];
UIView* v= [s objectAtIndex:0];
[self showModal:v]; 

And this is the method;

- (void) showModal:(UIView*) modalView {   
   UIWindow* mainWindow = (((AppDelegate_iPhone*) [UIApplication sharedApplication].delegate).window);
   CGSize offSize = [UIScreen mainScreen].bounds.size;
   CGPoint offScreenCenter = CGPointMake(offSize.width / 2.0, offSize.height * 1.5);
   modalView.center = offScreenCenter; // we start off-screen 
   [mainWindow addSubview:modalView];
   modalView.center=middleCenter;
}
Spring
  • 11,333
  • 29
  • 116
  • 185
  • Is there any reason why you don't just display viewcontroller which holds the webview with `presentModalViewController`? – rckoenes Sep 06 '11 at 13:56
  • @rckoenes it covers whole screen which I dont want – Spring Sep 06 '11 at 14:03
  • 1
    @XDeveloper The whole point of adding it to the Application Window is that it stays on top of everything. If you just want it on top of the table view add it to the view controller's view `[self.view addSubview:v]`. Configure its size and coordinates before that though. – Fran Sevillano Sep 06 '11 at 14:06
  • @Francisco Sevillano tnx your suggestions promising but when I tried I saw that the new subview has the scrolling and bouncing of the mainview but not the webview's scrolling.how can overcome this – Spring Sep 06 '11 at 14:21
  • @XDeveloper You should have two views inside the main view, the table view and the web view. When you want to show the webview, add it to the main view instead of to the table view. – Fran Sevillano Sep 06 '11 at 15:20

2 Answers2

1

Look how I accomplished that:

StatusChangedMsgView *temp = [[StatusChangedMsgView alloc] initWithFrame:CGRectMake(10, 66, 300, 35)];  
XUIAppDelegate *delegate = (XUIAppDelegate*)[UIApplication sharedApplication].delegate;
[delegate.window insertSubview:temp atIndex:[[delegate.window subviews]count]];

I hope it helps you!

Fran Sevillano
  • 8,103
  • 4
  • 31
  • 45
0

Please visit the link below, I hope this will help you out to display your view.

How to load a UIView using a nib file created with Interface Builder

Community
  • 1
  • 1
Pravara Patil
  • 513
  • 1
  • 3
  • 10
  • ohh sorry...here it is:http://stackoverflow.com/questions/863321/iphone-how-to-load-a-view-using-a-nib-file-created-with-interface-builder – Pravara Patil Sep 06 '11 at 15:16