iOS PopOver с веб-просмотром

Я пытаюсь создать всплывающее окно, которое отображает webView. Пока у меня есть кнопка, которая при нажатии создает всплывающее окно, но веб-представление не отображается. Используя NSlog, я вижу, что метод viewDidLoad срабатывает. Вот код, который у меня есть до сих пор:

В файле popover.h: @interface PopUpViewController : UIViewController

@property (сильное, неатомарное) IBOutlet UIWebView *liveTimingPopUp;

@конец

В файле popover.m:

#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

В представлении управления, содержащем кнопку, которая создает файл popover .m:

#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

Любая помощь будет принята с благодарностью!


person Alan    schedule 15.11.2012    source источник


Ответы (1)


откуда должен браться веб-просмотр? VC не получает имя xib .. поэтому торговая точка никогда не будет делать ставки

person Daij-Djan    schedule 15.11.2012
comment
Сейчас он просто висит на раскадровке. Я не совсем уверен, как это сделать. Я действительно новичок в ios и объективном C. Я парень на С++. - person Alan; 16.11.2012