2012-03-10 74 views
1

创建滑块怎样才能让controller1上下滑动通过它创建slider我怎么能在UIViewController中

-(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 Viewcontroller1controller1不上下滑动。

欣赏帮助。

+0

我有点糊涂了,你要根据滑块的值更新视图的由来?如果是这样,你不应该使用'presentModalViewController',因为它完全转换到/从视图,而不是逐步移动。 – axiixc 2012-03-10 20:24:06

+0

在我的viewcontroller我有很多文字可能是2或3页左右。我想添加滑块,以便用户可以上下滑动视图来阅读它。 – user1120133 2012-03-10 20:27:34

+0

为什么不把文本放在UITextView中呢?它将允许用户在不修改视图几何的情况下滚动文本。 – axiixc 2012-03-10 20:30:19

回答

1

从我可以告诉你想要做什么,我认为你应该使用UIScrollView并控制其contentOffset属性。我把一个快速示例应用程序放在一起,希望它能够实现你想要做的。

http://cl.ly/2Z3D1D0W1m332y313v0A