- [UINavigationController pushViewController:animated:]在控制台中没有错误崩溃

时间:2011-10-03 00:35:08

标签: iphone ios pushviewcontroller

更新

我为pushViewController换掉了完全不同的代码,它仍然崩溃......看起来像pushViewController不是罪魁祸首。这是我添加的内容:

NSString *videoURL = [[NSString alloc] initWithFormat:@"http://www.vimeo.com/m/#/%@", videoID];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:videoURL]];

它会在Safari中打开URL,然后崩溃.. wtf?


PushViewController在控制台中没有错误崩溃,但我在Xcode中遇到EXC_BAD_ACCESS错误。直到视图控制器被推动之后才会发生崩溃......但是它的推送视图是空的......没有代码可以搞砸。

我的代码如下:

MainViewController.m

PlayVimeo *playTest = [[PlayVimeo alloc] initWithNibName:@"PlayVimeo" bundle:nil];
    //playTest.videoID = videoID;
    [self.navigationController pushViewController:playTest animated:YES];
    [playTest release];

PlayVimeo.m

#import "PlayVimeo.h"
#import "SVProgressHUD.h"


@implementation PlayVimeo
@synthesize videoID, wView;

-(void)viewDidLoad {
    [super viewDidLoad];

    //Show loading alert
    [SVProgressHUD showInView:self.view status:@"Loading Video..."];
    }


-(void)viewWillAppear:(BOOL)animated {     

    NSLog(@"Play View Loaded!");

    [self vimeoVideo];
    }


-(void)vimeoVideo {

    NSLog(@"Video ID: %@", videoID);

    NSString *html = [NSString stringWithFormat:@"<html>"
                      @"<head>"
                      @"<meta name = \"viewport\" content =\"initial-scale = 1.0, user-scalable = no, width = 460\"/></head>"
                      @"<frameset border=\"0\">"
                      @"<frame src=\"http://player.vimeo.com/video/%@?title=0&amp;byline=0&amp;portrait=1&amp;autoplay=1\" width=\"460\" height=\"320\" frameborder=\"0\"></frame>"
                      @"</frameset>"
                      @"</html>", 
                      videoID];

    NSLog(@"HTML String: %@", html);

    [wView loadHTMLString:html baseURL:[NSURL URLWithString:@""]];

    //Dismiss loading alert
    [SVProgressHUD dismissWithSuccess:@"Playing..."];
    }



- (void)viewDidUnload {
    [super viewDidUnload];
    }

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
    }

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    }

-(void)dealloc {
    [super dealloc];
    }

导航控制器代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {   
    self.window.rootViewController = self.navigationController;
    [self.window makeKeyAndVisible];

    [Appirater appLaunched];

    return YES;
    }

崩溃控制台:

sharedlibrary apply-load-rules all
Current language:  auto; currently objective-c
(gdb) 

2 个答案:

答案 0 :(得分:0)

罪魁祸首可能是

[playTest release];

如果没有看到您的其他代码,我仍然会说您可能需要在完成视频后发布此代码。

答案 1 :(得分:0)

似乎代码无法修复。使用UIWebView类引用,有一个示例程序TransWeb。以此为基础,它有一个窗口和一个带有webview的导航控制器(在xib中)。在MyViewController中,它会读取一个html文件并显示它。您需要做的是将主视图更改为横向并用您的html代码替换。避免使用框架。