iPhone App收听广播

时间:2012-11-14 20:57:54

标签: iphone objective-c ios xcode

我想创建一个允许人们收听广播的iPhone应用程序。以下是我到目前为止所做的事情,但当我点击按钮时没有任何事情发生,有人可以告诉我这里做错了什么。

提前致谢。

#import <UIKit/UIKit.h>

@interface RadioViewController : UIViewController{

IBOutlet UIWebView *webView;
}

-(IBAction)radio;
@property(nonatomic,retain)UIWebView *webview;

@end


#import "RadioViewController.h"
#import <MediaPlayer/MediaPlayer.h>
@implementation RadioViewController

@synthesize webview;

-(IBAction)radio{

    NSURL *url = [NSURL URLWithString:@"http://db5195728.tis.core.005.cdn.streamfarm.net:80/3212_erf_96_live.mp3"];
    NSURLRequest *req = [NSURLRequest requestWithURL: url];
    [webview loadRequest:req];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

1 个答案:

答案 0 :(得分:1)

我已经尝试过你的代码了。它在这里工作正常。所以:

  1. 点按该按钮,确保调用radio。您可以在那里设置断点或添加NSLog以查看它是否被调用;
  2. 确保您的webview正确添加到您的视图中:显示且尺寸正确。
相关问题