我在的PageControl 15幅圖像,我在我的應用程序如何使用的PageControl
有15個按鈕現在,如果我當時像5從頁面應控制在按下按鈕5獲得的觀察中心的圖像屏幕的中心。
,如果我在離網頁控件,實時圖像10按下按鈕10應該是在屏幕的中央。
我如何開發這種結構在我的應用程序?
分享你的想法。
thanx提前。
我在的PageControl 15幅圖像,我在我的應用程序如何使用的PageControl
有15個按鈕現在,如果我當時像5從頁面應控制在按下按鈕5獲得的觀察中心的圖像屏幕的中心。
,如果我在離網頁控件,實時圖像10按下按鈕10應該是在屏幕的中央。
我如何開發這種結構在我的應用程序?
分享你的想法。
thanx提前。
嘗試用這個(假設你使用的是滾動型與分頁啓用):
-(IBAction)goToPage5:(id)sender{
CGRect frame = self.scrollView.frame;
frame.origin.x = frame.size.width * 5;
//OR if you have set the tags to your buttons:
//UIButton *b=(UIButton*)sender;
//frame.origin.x = frame.size.width * b.tag;
self.pageControl.currentPage=5;
frame.origin.y = 0;
[self.scrollView scrollRectToVisible:frame animated:YES];
}
將相同的標籤分配給您的按鈕&對應的圖像。
獲取有關按鈕操作的按鈕標記。
使用按鈕標籤(兩個標籤 將相同)
獲取MAINVIEW頁控制的相同的幀的中心的圖像位置
滾動/可見光獲得從視圖中的對應圖像的 主視圖
爲每個按鈕分配標籤並初始化一個imageview的
-(IBAction)YourButtonName:(UIButton *)sender
{
imageview.image=[UIImage imageNamed:UIImage imageNamed:[NSString stringWithFormat:@"image%d",sender.tag];
imageview.center=self.view.center;
}