iOS PopOver与Webview
我正在尝试构建一个弹出窗口来显示网络视图。到目前为止,我有一个按钮,当按下时,会生成一个弹出窗口,但不会显示web视图。使用NSlog,我可以看到viewDidLoad方法正在启动。以下是我目前掌握的代码: 在popover.h文件中: @接口PopUpViewController:UIViewController @属性(强,非原子)IBUIWebView*liveTimingPopUp @结束 在popover.m文件中:iOS PopOver与Webview,ios,webview,popover,Ios,Webview,Popover,我正在尝试构建一个弹出窗口来显示网络视图。到目前为止,我有一个按钮,当按下时,会生成一个弹出窗口,但不会显示web视图。使用NSlog,我可以看到viewDidLoad方法正在启动。以下是我目前掌握的代码: 在popover.h文件中: @接口PopUpViewController:UIViewController @属性(强,非原子)IBUIWebView*liveTimingPopUp @结束 在popover.m文件中: #import "PopUpViewController.h" @
#import "PopUpViewController.h"
@interface PopUpViewController ()
@end
@implementation PopUpViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self loadWebView];
}
- (void) loadWebView
{
// Do any additional setup after loading the view.
NSString *fullURL = @"www.google.com";
NSURL *url = [NSURL URLWithString:fullURL];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[_liveTimingPopUp loadRequest:requestObj];
[self loadView];
NSLog(@"PopUpView Fired");
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
在包含生成popover.h文件的按钮的控件视图中:
#import <UIKit/UIKit.h>
@interface SecondViewController : UIViewController
{
UIInterfaceOrientation intOr;
// APICallsViewController *pendingApiCallsController;
}
@property (strong, nonatomic) IBOutlet UIWebView *liveVideoPage;
- (IBAction)liveTimingButton:(id)sender;
@property (strong, retain) UIPopoverController *popOver; //declare UIPopOver so that you have an object to work with
-(void) loadVideo;
@end
任何帮助都将不胜感激 网络视图应该来自哪里?未向VC传递xib名称。。因此,现在这个出口永远不会下注,它只是挂在故事板上。我真的不知道该怎么做。我对ios和objective C非常陌生。我是一个C++的家伙。
#import "SecondViewController.h"
#import "PopUpViewController.h"
@interface SecondViewController ()
@end
@implementation SecondViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self loadVideo];
}
- (void) loadVideo
{
NSString *fullURL = @"http://192.168.130.230:1935/live/camera.stream/playlist.m3u8";
NSURL *url = [NSURL URLWithString:fullURL];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[_liveVideoPage loadRequest:requestObj];
}
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
intOr = self.interfaceOrientation;
if (intOr == UIInterfaceOrientationPortrait)
{
NSLog(@"portrait");
_liveVideoPage.frame = CGRectMake(10, 100, 600, 550);
}
else
{
NSLog(@"landscape");
_liveVideoPage.frame = CGRectMake(200, 100, 600, 550);
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)liveTimingButton:(id)sender
{
if ([_popOver isPopoverVisible]) {
[_popOver dismissPopoverAnimated:YES];
}
else
{
PopUpViewController *PUVC = [[PopUpViewController alloc]init];//instantiate ViewController for popOver's content
_popOver = [[UIPopoverController alloc] /* create Popover*/initWithContentViewController:PUVC]; //fills popover with PopUpViewController
_popOver.popoverContentSize = CGSizeMake(800, 250);
[_popOver presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; //specifies where the popover is coming from...the liveTiming Bar button
}
}
@end