相关疑难解决方法(0)

automaticAdjustsScrollViewInsets不起作用

我已经创建了一个非常简单的演示应用来测试其功能automaticallyAdjustsScrollViewInsets,但是我的标签栏覆盖了tableView的最后一个单元格.

我的AppDelegate代码:

UITabBarController *tabControl = [[UITabBarController alloc] init];
tabControl.tabBar.translucent = YES;
testViewController *test = [[testViewController alloc] init];
[tabControl setViewControllers:@[test]];

[self.window setRootViewController:tabControl];
Run Code Online (Sandbox Code Playgroud)

我的testViewController(UITableViewController的子类)代码:

- (void)viewDidLoad
{
[super viewDidLoad];
self.automaticallyAdjustsScrollViewInsets = YES;
self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds];
self.tableView.dataSource = self;
self.tableView.scrollIndicatorInsets = self.tableView.contentInset;
//[self.view addSubview:self.tableView];

// Do any additional setup after loading the view.
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 20;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@""];
cell.textLabel.text = @"test"; …
Run Code Online (Sandbox Code Playgroud)

objective-c uiscrollview uitabbar ios ios7

29
推荐指数
3
解决办法
3万
查看次数

在全屏幕上强制横向方向MPMoviePlayerController在退出全屏时阻止正确旋转

我有一个支持所有界面方向的iPhone应用程序(iOS6 +).但是,当MPMoviePlayerController正在播放全屏视频时,应仅支持横向.

我在Stack Overflow上找到了以下解决方案,它可以工作.

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerWillEnterFullscreenNotification:) name:MPMoviePlayerWillEnterFullscreenNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerWillExitFullscreenNotification:) name:MPMoviePlayerWillExitFullscreenNotification object:nil];
Run Code Online (Sandbox Code Playgroud)

...

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    if (self.landscapeOnlyOrientation) {
        return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
    }
    return UIInterfaceOrientationMaskAll;
}

- (void)moviePlayerWillEnterFullscreenNotification:(NSNotification*)notification {
    self.landscapeOnlyOrientation = YES;
}

- (void)moviePlayerWillExitFullscreenNotification:(NSNotification*)notification {
    self.landscapeOnlyOrientation = NO;
}
Run Code Online (Sandbox Code Playgroud)

然而,一个恼人的问题仍然存在,即如果视频以纵向方向退出全屏(在强制风景中播放之后),则底层视图不会向后旋转.我必须手动将设备旋转到横向并返回到纵向以触发更新方向.有没有什么方法可以以编程方式触发这种更新?

以下一组截图应说明我的意思:

在此输入图像描述 在此输入图像描述 在此输入图像描述

注意:由于各种原因,无法使用MPMoviePlayerViewController.

iphone objective-c mpmovieplayercontroller uiinterfaceorientation ios

14
推荐指数
2
解决办法
1万
查看次数