简体   繁体   English

我如何在UIViewController中创建滑块

[英]How can i create slider in UIViewController

How can i make controller1 slide up and down by creating slider in it 我如何通过在其中创建slider来使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;
    }

I got this from User Experience Coding How-To's from Apple Reference for creating slider 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;

I added this whole thing right below UIText View in controller1 but controller1 is not sliding up and down. 我在controller1 UIText View下添加了整个UIText View ,但是controller1并没有上下滑动。

Appreciate help. 感谢帮助。

From what I can tell about what you are trying to do, I think you should be using a UIScrollView and taking control of its contentOffset property. 从我可以说出您要做什么的角度,我认为您应该使用UIScrollView并控制其contentOffset属性。 I threw together a quick example app, hopefully its what you are trying to do. 我整理了一个快速的示例应用程序,希望它是您正在尝试做的事情。

http://cl.ly/2Z3D1D0W1m332y313v0A http://cl.ly/2Z3D1D0W1m332y313v0A

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM