1

我的应用程序中有两个带有选择器视图的按钮。在纵向模式下,这些按钮位于左侧,当我将设备的方向更改为横向时,按钮会移至屏幕右侧,但选择器视图仅保留在左侧。我需要选择器改变它的位置并移动到右侧。

关于如何做到这一点的任何想法?

4

3 回答 3

1

我已经对我的代码进行了以下更改,并且我得到了所需的结果....

-(void) didReceivedRotaionChanged
{
    if([popoverController isPopoverVisible])
    {
        if ([popoverController.contentViewController isKindOfClass:[UINavigationController class]])
        {
            UINavigationController * navController = (UINavigationController*)popoverController.contentViewController;
            NSArray *array = navController.viewControllers;
            if ([array count] > 0)
            {
                if([[array objectAtIndex:0] isEqual:self.nsJobRolePickerViewController])
               {
                    [popoverController dismissPopoverAnimated:NO];
                    [self onClickIJobRoleButton:self.btnJobRole];

                }
                else if([[array objectAtIndex:0] isEqual:self.nsLocationPickerViewController])
                {
                    [popoverController dismissPopoverAnimated:NO];
                    [self onClickILocationButton:self.btnLocation];

                }
            .
            .
            ......

ETC..

嗯,它有点冗长......但它会帮助像我这样的初学者......

于 2013-01-17T11:45:08.500 回答
1

制作您的pickerView的对象。为它设置@property 和@synthesixe。在您的 .xib 中建立连接!然后在您的 viewDidLoad() 中编写以下代码!

pickerViewObject.autoresizingMask= UIViewAutoresizingFlexibleRightMargin;

如果您想添加多个自动调整大小的蒙版,请使用 | 操作员。!!

pickerViewObject.autoresizingMask= UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin;
于 2013-01-16T09:00:38.767 回答
0

您必须取消选中 .xib 中的 Utilities -> File Inspector 中可用的“AutoLayout”选项!

于 2013-01-16T07:42:57.233 回答