我想创建一个 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
最佳答案
我试过你的代码。它在这里工作正常。所以:
- 确保在您点击该按钮时调用您的
radio
。可以在那里设置断点或者加一个NSLog
看是否被调用; - 确保您的
webview
已正确添加到您的 View :已显示且大小正确。
关于iPhone 应用程序收听广播,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13387192/