In my universal app I am trying to show webview in a ui开发者_开发百科alertsheet but getting weird results, why is that webview shifted on left? and ok button is on the top? I want to just center and nicely fit to the uisheet window but with the OK button clickable on the bottom
You can also simply ignore my code and may tell how to accomplish this.
tnx
UIActionSheet *msgSheet = [[[UIActionSheet alloc]
initWithTitle:@"x"
delegate:nil
cancelButtonTitle:nil destructiveButtonTitle:nil
otherButtonTitles:@"OK", nil]
autorelease];
UIWebView *w=[[UIWebView alloc] init];
[w loadHTMLString:theString baseURL:nil];
[msgSheet addSubview:w];
[w release];
[msgSheet showInView:self.view];
[msgSheet setOpaque:NO];
[msgSheet setAlpha:0.7];
CGRect wRect = msgSheet.bounds;
w.bounds = wRect;
CGRect menuRect = msgSheet.frame;
CGFloat orgHeight = menuRect.size.height;
menuRect.origin.y -= 150; //height of webview
menuRect.size.height = orgHeight+150;
msgSheet.frame = menuRect;
CGRect wRect = w.frame;
wRect.origin.y = orgHeight;
w.frame = wRect;
CGSize mySize = msgSheet.bounds.size;
CGRect myRect = CGRectMake(0, 0, mySize.width, mySize.height);
UIImageView *redView = [[[UIImageView alloc] initWithFrame:myRect] autorelease];
[blueView setBackgroundColor:[[UIColor APP_TINT_COLOR] colorWithAlphaComponent:0.6]];
[msgSheet insertSubview:blueView atIndex:0];
I solved the problem easily simply by reading this article;
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaViewsGuide/Coordinates/Coordinates.html
精彩评论