2013-02-27 54 views
0

我有6個UIButton控件放置在UIScrollView中。 按鈕水平對齊,但一次只能看到3.5個空間。移動UIScrollView,使UIButton完全顯示

我想要發生的是當我觸摸半可視按鈕 - 讓UIScrollView移動其內容,使觸摸的按鈕將完全可見(如過濾條如何在Instagram中工作)。

回答

2
- (IBAction)buttonPressed:(id)sender{ 
     [scrollView scrollRectToVisible:sender.frame animated:YES]; 
     //your code 
} 

將操作添加到按鈕。

+0

非常棒!謝謝!有沒有辦法在按鈕和滾動視圖邊緣之間添加一些邊距? – YogevSitton 2013-02-27 12:10:10

+1

sender.frame => CGRectInset(sender.frame,-10,-10) – Sk0prion 2013-02-27 12:19:25