小编133*_*ode的帖子

UINavigationController中的ViewController方向更改

所以我有以下层次结构:

UINavigationController- > RootViewController(UIViewController) - > UITableViewController- > DetailViewController(UIViewController)

我想将RootViewController上的方向锁定为仅限纵向,但保留其余视图控制器的所有方向.

如果我把它放到子类中UINavigationController:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)

然后将所有视图控制器锁定为纵向.

我的问题是,有没有办法只将RootViewController锁定为Portrait,但保留其他视图控制器的所有选项?

iphone orientation uinavigationcontroller ipad ios

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

UISearchBar文本字段中的自定义清除按钮

我试过了:

UITextField *searchtextfield = [searchBar.subviews objectAtIndex:1];
    UIButton *cButton = [UIButton buttonWithType:UIButtonTypeCustom];
    cButton.frame = CGRectMake(0, 0, 20 , 20);
    cButton.backgroundColor = [UIColor clearColor];
    [cButton setImage:[UIImage imageNamed:@"x-button"] forState:UIControlStateNormal];//your button image.
    cButton.contentMode = UIViewContentModeScaleToFill;
    [cButton addTarget:self action:@selector(xButtonPressed) forControlEvents:UIControlEventTouchUpInside];//This is the custom event
    [searchtextfield setRightView:cButton];
    [searchtextfield setRightViewMode:UITextFieldViewModeWhileEditing];
Run Code Online (Sandbox Code Playgroud)

但它不能很好地工作......它显示自定义按钮,但是当你输入一些东西时,旧的东西会回来......

我怎样才能做到这一点?

iphone uitextfield uisearchbar ipad ios

6
推荐指数
3
解决办法
8444
查看次数

iOS 5中的iPad方向问题

我在StoryBoard中有UISplitViewController,它是初始视图,我希望该应用程序仅在横向模式下工作.

我只限制了横向方向,甚至将横向界面方向设置为横向(右侧主页按钮).

在iOS 6中,一切正常,它只显示主视图和详细视图,但在iOS 5中它停留在纵向模式,只显示详细信息视图.

请帮我这个,我坚持了2个小时......

iphone landscape orientation ipad ios

1
推荐指数
1
解决办法
783
查看次数

MPMoviePlayerController在全屏中添加子视图

我试过这个但是没有用,我在过去7个小时里一直在努力,请帮助我.我想在MPMoviePlayer的全屏视图中添加自定义按钮.

码:

moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];

        [self.view addSubview:moviePlayerController.view];
        moviePlayerController.fullscreen = YES;

        UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];

        CustomControlsViewController *overlay = (CustomControlsViewController*)[mainStoryBoard instantiateViewControllerWithIdentifier:@"Custom Controls"];

        [moviePlayerController.view addSubview:overlay.view];

        [moviePlayerController play];
Run Code Online (Sandbox Code Playgroud)

controls add objective-c subview mpmovieplayercontroller

1
推荐指数
1
解决办法
4402
查看次数

UITableViewController在推送时没有导航栏

我正在使用此代码

-(void)gotoInformationViewController:(id)sender
{
    MoreViewController *moreViewController = [[MoreViewController alloc] init];
    [self.navigationController pushViewController:moreViewController animated:YES];
    [moreViewController release];
}
Run Code Online (Sandbox Code Playgroud)

推动一个MoreViewController(这是UITableViewController),但它UINavigationBar在推动时没有,只是UITableView在整个屏幕上.

iphone uitableview uinavigationcontroller ipad ios

0
推荐指数
1
解决办法
1700
查看次数

@try @catch阻止在iOS 6上工作但在iOS 5上没有

我有一个在单元格中有2个子视图的tableview(带标签的小缩略图),如果没有任何内容可以加载(当只有第一个子视图有加载的图像和标题时)我想要隐藏第二个子视图.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *reuse = @"reuse";
    ContentTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:[Utils buildNibNameFromPrefix:@"ContentTableViewCell"] owner:self options:nil] objectAtIndex:0];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }

    cell.cellIndex = indexPath.row;

    NSUInteger selectedIndex = [Utils getIndexForContentTitle:[Utils getContentBookmark]];
    NSUInteger titleIndex = indexPath.row * self.noOfContentPerCell;
    NSUInteger cellIndex = NSNotFound;
    for (int i = 0; i < self.noOfContentPerCell; i++) {
        @try {
            if (titleIndex == selectedIndex) {
                cellIndex = i;
            }

            NSArray *content;
            if ([[NSUserDefaults standardUserDefaults] …
Run Code Online (Sandbox Code Playgroud)

iphone try-catch ipad ios

-1
推荐指数
1
解决办法
1062
查看次数