如何在iPhone中以编程方式添加下一个和上一个按钮? [英] How to add next and previous buttons programmatically in iPhone?
本文介绍了如何在iPhone中以编程方式添加下一个和上一个按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在图像视图中,如何在iPhone中以编程方式添加下一个和上一个按钮(前后选项)?
Here in image view, how to add next and previous buttons (front and back options) programmatically in iPhone?
推荐答案
在图像视图中添加按钮?
Adding Button in image View?
如果是,则代码如下
UIButton *nextBut=[UIButton buttonWithType:UIButtonTypeRoundedRect];
nextBut.frame= CGRectMake(x, y, 120, 100);
[nextBut setTitle:@"Next" forState:UIControlStateNormal];
[nextBut addTarget:self action:@selector(nextbuttonAction) forControlEvents:UIControlEventTouchUpInside];
[self.imageView addSubview:nextBut];
[nextBut release];
UIButton *prevBut=[UIButton buttonWithType:UIButtonTypeRoundedRect];
prevBut.frame= CGRectMake(x, y, 120, 100);
[prevBut setTitle:@"Previous" forState:UIControlStateNormal];
[prevBut addTarget:self action:@selector(prevbuttonAction) forControlEvents:UIControlEventTouchUpInside];
[self.imageView addSubview:prevBut];
[prevBut release];
x,y是按钮在视图中的位置.
x,y is the position of the button in your view.
然后输入按钮操作的代码
Then code for the button actions,
-(IBAction)nextbuttonAction
{
//Next Button Action
}
-(IBAction)prevbuttonAction
{
//Previous Button Action
}
设置pickerView委托.在以下方法代码中,
set the pickerView delegate. In the following method code as follows,
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
imageView.image=[UIImage imageNamed:[imageArray objectAtIndex:row]];
}
这篇关于如何在iPhone中以编程方式添加下一个和上一个按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文