更改 UIPickerView 行高

发布于 2024-11-16 02:47:07 字数 168 浏览 3 评论 0原文

我正在为我正在参加的课程编写一个程序,该程序的一部分需要一个包含图像的 UIPickerView 。我已启动并运行选择器,但选择器中的行高度仍然太小,导致图像 (100x100) 重叠。我正在寻找一种更改 UIPickerView 的方法,以便图像适合一行而不重叠。谢谢

I'm working on a program for a class I'm taking and part of the program requires a UIPickerView with images in it. I have the picker up and running, but the height of the rows in the picker are still too small, causing the images (100x100) to overlap. I'm looking for a way to change the UIPickerView so that the images will fit in one row, without overlapping. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浮生面具三千个 2024-11-23 02:47:07

UIPickerView,您有一个指向 UIPickerViewDelegate 协议。您可以实现一个方法,pickerView:rowHeightForComponent:

In the documentation for the UIPickerView, you have a link to the UIPickerViewDelegate protocol. There is a method that you can implement, pickerView:rowHeightForComponent:.

戈亓 2024-11-23 02:47:07

使用此方法,提供默认值作为委托方法。

objective-C

- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
{
    return 40;
}

在 Swift 中:

func pickerView(pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat 
{   
    return 40
}

了解更多信息,请访问:现实世界的实现

use this method,provide default as a delegete method.

objective-C

- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
{
    return 40;
}

In Swift:

func pickerView(pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat 
{   
    return 40
}

for more visit : real world implementation

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文