UISegmentedControl按下视图

时间:2012-09-08 13:16:41

标签: xcode uitableview uiview uisegmentedcontrol

每次按下相同的段后,我的表视图控制器将从一个单元格大小的视图中下推。任何人都有想法为什么会发生?其他不包含任何表视图的视图都可以正常工作。 以下是图片enter image description here

的外观

编辑:评论中的代码:

- (void)indexDidChangeForSegmentedControl:(UISegmentedControl *)aSegmentedControl {
    NSUInteger index = aSegmentedControl.selectedSegmentIndex;
    UIViewController * incomingViewController = [self.viewControllers objectAtIndex:index];
    NSArray * theViewControllers = [NSArray arrayWithObject:incomingViewController];
    [self.navigationController setViewControllers:theViewControllers animated:NO];
    incomingViewController.navigationItem.titleView = aSegmentedControl;
}

- (void)tableView: (UITableView*)tableView willDisplayCell: (UITableViewCell*)cell forRowAtIndexPath: (NSIndexPath*)indexPath {
    cell.backgroundColor = indexPath.row % 2 ? [UIColor colorWithRed:216.0f/255.0f green:235.0f/255.0f blue:213.0f/255.0f alpha:1.0f] : [UIColor colorWithRed:178.0f/255.0f green:107.0f/255.0f blue:146.0f/255.0f alpha:1.0f];
    cell.textLabel.font = [UIFont fontWithName:@"CaviarDreams" size:23];
    cell.textLabel.textColor = indexPath.row % 2 ?[UIColor colorWithRed:178.0f/255.0f green:107.0f/255.0f blue:146.0f/255.0f alpha:1.0f] :[UIColor colorWithRed:216.0f/255.0f green:235.0f/255.0f blue:213.0f/255.0f alpha:1.0f];
    cell.textLabel.backgroundColor = [UIColor clearColor];
    cell.detailTextLabel.backgroundColor = [UIColor clearColor];
}

0 个答案:

没有答案