如何在UIViewController中创建滑块

时间:2012-03-10 19:16:00

标签: iphone

如何通过在其中创建controller1来使slider向上和向下滑动

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {


switch (buttonIndex) {

    case 0:{

        //Devanagari view display 

        ButtonViewController *controller1 = [[ButtonViewController alloc]init];

        controller1.delegate = self;

        UINavigationController *navigationController = [[UINavigationController alloc]
                                                        initWithRootViewController:controller1];
        navigationController.navigationBar.tintColor = [UIColor colorWithHue:2.0/12 saturation:2.0 brightness:4.0/10 alpha:1.0];

        [self presentModalViewController:navigationController animated:YES];

        [navigationController release];

        break;
    }

我从User Experience Coding How-To's from Apple Reference获得此信息,用于创建slider

CGRect frame = CGRectMake(0.0, 0.0, 200.0, 10.0);
UISlider *slider = [[UISlider alloc] initWithFrame:frame];
[slider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
[slider setBackgroundColor:[UIColor clearColor]];
slider.minimumValue = 0.0;
slider.maximumValue = 50.0;
slider.continuous = YES;
slider.value = 25.0;

我在UIText View controller1 controller1下面添加了整件事,但{{1}}没有上下滑动。

感谢帮助。

1 个答案:

答案 0 :(得分:1)

从我所知道的你要做什么,我认为你应该使用UIScrollView并控制其contentOffset属性。我把一个快速的示例应用程序拼凑在一起,希望它是你想要做的。

http://cl.ly/2Z3D1D0W1m332y313v0A