简体   繁体   English

尝试在vrf-reader ContentView顶部添加UIButton

[英]Trying to add UIButton on top of vrf-reader ContentView

I am trying to insert some buttons in the PDF page rendered by the open source iOs reader vfr-reader https://github.com/vfr/Reader 我正在尝试在由开源iOs阅读器vfr-reader https://github.com/vfr/Reader呈现的PDF页面中插入一些按钮

Basically this is the code I am trying to implement in the initWithFrame method of ReaderContentView: 基本上,这是我尝试在ReaderContentView的initWithFrame方法中实现的代码:

if (theContentView != nil) // Must have a valid and initialized content view { if(theContentView!= nil)//必须具有有效且已初始化的内容视图{

UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [myButton setFrame:CGRectMake(269, 262, 100, 100)];
        [myButton addTarget:self action:@selector(links) forControlEvents:UIControlEventTouchUpInside];
        [myButton setTitle:@"asdasd" forState:UIControlStateNormal];
        [theContentView addSubview:myButton];

The button doesn't work, and I can see that it is rendered and flattened in some way so it doesn't seem to be a button anymore as you can see here at full zoom. 该按钮不起作用,我可以看到它已以某种方式进行了渲染和展平,因此它似乎不再是一个按钮,因为您可以在此处以最大缩放比例看到它。

uibutton似乎很模糊 However running DCInspector, despite warning that 尽管警告说,但是运行DCInspector

2013-05-24 12:27:34.560 Reader[45333:c07] DCIntrospect: *** WARNING: One or more values of this view's frame are non-integer values. This view will likely look blurry. ***

seems to identify the button properly when inspected. 在检查时似乎可以正确识别按钮。

To test this case, just download the reader project and put my code in ReaderContentView at line 113. I am pretty sure I am doing something totally wrong. 要测试这种情况,只需下载阅读器项目,然后将我的代码放在第113行的ReaderContentView中。我很确定自己做的事情完全错误。 Thank you for help! 谢谢你的帮助!

it was a bit tricky but I discovered that userInteractionEnabled was not set properly on the container view. 这有点棘手,但是我发现在容器视图上没有正确设置userInteractionEnabled。 I should have supposed that :) 我应该以为:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM