2012-03-10 73 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