我有一个带有tabbar的应用程序,我想在其中检测界面方向.
我在info.plist中设置了支持的方向.这是我的主要接口声明:
@interface MyAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
...
}
Run Code Online (Sandbox Code Playgroud)
这是在MyAppDelegate的实现中:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
return NO;
if (interfaceOrientation == UIInterfaceOrientationLandscapeRight)
return YES;
if (interfaceOrientation == UIInterfaceOrientationPortrait)
return YES;
if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
return NO;
}
Run Code Online (Sandbox Code Playgroud)
在我试图检测方向变化的必要视图中,我称之为以下方法:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;
Run Code Online (Sandbox Code Playgroud)
和
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation;
Run Code Online (Sandbox Code Playgroud)
我已经在这些方法中设置了NSLog打印,它们都没有注册任何更改.甚至没有在shouldAutorotateToInterfaceOrientation方法中.
谁能帮帮我吗?我做错了什么?任何帮助将不胜感激.
我知道这种问题反复浮动一遍又一遍,但我找不到任何答案,我无法解决我的问题:(.
我正在开发一个应用程序,我需要获取音频流.我决定和MPMoviePlayer一起去,所以我这样做了:
#import "MediaPlayer/MediaPlayer.h"
@interface FirstViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
...
IBOutlet MPMoviePlayerViewController *theMovie;
...
}
...
@property (nonatomic, retain) MPMoviePlayerViewController *theMovie;
Run Code Online (Sandbox Code Playgroud)
在实现中,我只是@ synthesize -d它.
现在,每当我分配它并尝试访问它的成员或方法时,我得到这个该死的错误无法识别的选择器在初始化后的第一行发送到实例:
self.theMovie = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:@"http://netvarp.kringvarp.fo:554/radio/16/playlist.m3u8"]];
self.theMovie.moviePlayer.controlStyle = MPMovieControlStyleNone;
...
Run Code Online (Sandbox Code Playgroud)
(这是在viewDidLoad方法中).
我在这行中得到错误:
self.theMovie.moviePlayer.controlStyle = MPMovieControlStyleNone;
Run Code Online (Sandbox Code Playgroud)
或者我在初始化后调用的任何东西.
如果我删除IBOutlet,如果我在没有'self'的情况下调用它,如果声明一个MPMoviePlayerController,也是如此.我无法弄清楚我2天做错了什么!真难为情 :(
任何帮助将不胜感激.
我忘了提及,目标操作系统> 3.0.在模拟器上一切正常,但在设备上没有(iPhone 2G和iPhone 3G,都是IOS 3.1.3)