4000-520-616
欢迎来到免疫在线!(蚂蚁淘生物旗下平台)  请登录 |  免费注册 |  询价篮
主营:原厂直采,平行进口,授权代理(蚂蚁淘为您服务)
咨询热线电话
4000-520-616
当前位置: 首页 > 新闻动态 >
热卖商品
新闻详情
Best way to observe touchesBegan on an MGLine?-CSDN问答
来自 : CSDN技术社区 发布时间:2021-03-24

私信 访问主页

\"weixin_39641231\" weixin_39641231 2020-12-02 11:46 首页 开源项目 Best way to observe touchesBegan on an MGLine?

Hey there,

Loving MGBox2 so far. I m looking to change the state of a MGLine when the user taps on it, before the finger is released, a lot like the selection highlight on a UITableViewCell.

Any ideas?

Thanks!

该提问来源于开源项目 sobri909/MGBoxKit

点赞 写回答 收藏 复制链接分享 删除 再等等 结题 再想想 12条回答

私信 访问主页

\"weixin_39892481\" weixin_39892481 3月前

Thank you for MGBox2 ! It s great !

Like jpap, 1 vote for the touch down event handling and highlight and 1 for the issue #42 Publish the development branch :)

点赞 评论 复制链接分享

私信 访问主页

\"weixin_39564368\" weixin_39564368 3月前

Recently started using MGBox2. Loving it, thank you! :)

1 vote for the touch down event handling and highlight.

点赞 评论 复制链接分享

私信 访问主页

\"weixin_39944375\" weixin_39944375 3月前

Possibly can get away with a shadow on the scroll view / containing box then.

I m hopefully going to do a chunk of work on MGLine this weekend, as there s a bunch of bugs/limitations that ve popped up since release. It ll most likely involve a BC break, with MGLine becoming a raw base class (ie no underlines), and adding a new MGLineStyled which includes underlines, highlighting, default padding, etc.

点赞 评论 复制链接分享

私信 访问主页

\"weixin_39641231\" weixin_39641231 3月前

Thanks for your detailed reply. There s not much scrolling or animation in my app, so I ve moved the shadow to the scrollView and it looks lovely.

点赞 评论 复制链接分享

私信 访问主页

\"weixin_39944375\" weixin_39944375 3月前

Ask Apple :) That limitation drives me crazy.

Options are usually a) put the corner radius on the inner item (ie the row), or b) wrap the whole table section in another view which you use solely for generating the shadow.

You could set the shadow on the scroll view or box that s holding all the table sections, but then you can t [easily] set a shadow path, which will possibly cause scrolling/animation stutters.

I m inclined to think it might be best to put the radius on the top and bottom rows of the section, because that avoids maskToBounds, and avoids nasty shadow hacks. But it means that instead of getting away with just setting a background colour on the row, you d need to do something like add a coloured shape layer with a path that has only two corners rounded.

The code for building and managing such a layer wouldn t be too bad, and probably has less side effects than masking/shadow hacks.

点赞 评论 复制链接分享

私信 访问主页

\"weixin_39641231\" weixin_39641231 3月前

Aw shucks, you are correct, it did destroy the shadow. Setting the backgroundColor of a MGLine was destroying the cornerRadius... any way to have it both ways?

Edit: obvious option is to create a wrapper view.

点赞 评论 复制链接分享

私信 访问主页

\"weixin_39944375\" weixin_39944375 3月前

Cool. Looks not too arduous in the end. This is something that should be rolled into MGBox proper, I think, so I ll keep this issue open.

Be wary of the masksToBounds, as it ll probably destroy any shadow you had on the table section.

点赞 评论 复制链接分享

私信 访问主页

\"weixin_39641231\" weixin_39641231 3月前

Got this working by adding the following to MGLine.m:

 objectivec- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [super touchesBegan:touches withEvent:event]; self.backgroundColor [UIColor colorWithRed:0.868 green:0.871 blue:0.880 alpha:1.000];- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { [super touchesEnded:touches withEvent:event]; self.backgroundColor nil;

And also, for cornerRadius, adding self.layer.masksToBounds YES; to the setup function in MGTableBoxStyled.m

点赞 评论 复制链接分享

私信 访问主页

\"weixin_39641231\" weixin_39641231 3月前

No go there... but I ll keep trying and will report back when I have something working! Thanks for your help.

点赞 评论 复制链接分享

私信 访问主页

\"weixin_39944375\" weixin_39944375 3月前

Hm. On the face of it that looks like it should work fine. Maybe you need to call super in your touchesBegan? Not sure. Worth a try.

点赞 评论 复制链接分享

私信 访问主页

\"weixin_39641231\" weixin_39641231 3月前

Thanks for your help.

I ve done this:

 objectivecMGLine *line [MGLine lineWithLeft: test right:nil size:CGSizeMake(BOX_WIDTH, 42)];SSUITapGestureRecognizer *tapper [[SSUITapGestureRecognizer alloc] initWithTarget:line action:(tapped)];tapper.delegate line;line.tapper tapper;line.onTap ^{ NSLog( you tapped my box! 

With SSUITapGestureRecognizer being a simple:

 objectivec- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event UITouch *firstTouch [[touches allObjects] objectAtIndex:0]; MGLine *line (MGLine *)firstTouch.view; line.backgroundColor [UIColor colorWithRed:0.918 green:0.98 blue:0.969 alpha:1]; line.layer.cornerRadius 4.0;

The background color shows up correctly, but the onTap event is never fired. Any suggestions? If this consumes too much of your time, I m happy to just play around until I get a working solution :)

点赞 评论 复制链接分享

私信 访问主页

\"weixin_39944375\" weixin_39944375 3月前

Hm. Interesting. I think the way I d go about it is to make a UITapGestureRecognizer subclass and assign it to the line s tapper property (making sure to set the new tapper s delegate to the line). In the subclass I d defined a touchesBegan:withEvent: method, and do the manipulation in there.

That way you can still set an onTap block to do whatever steps you want to happen once the tap is complete.

Although that does feel like a bit of an awkward solution. Perhaps it s something that should be rolled into MGBox proper, in that all tappers/swipers/etc should be custom subclasses that provide easier access to the touchesBegan/etc.

点赞 评论 复制链接分享 提交 再想想 采纳 为你推荐 如何检测已删除的文件? it技术互联网问答IT行业问题计算机技术编程语言问答 1个回答普罗米修斯直方图矢量:所有桶均装满吗? prometheus 2个回答如何减少gccgo编译的可执行文件所需的虚拟内存? linux 2个回答运行Hello Couchbase应用程序时出现紧急运行时错误[关闭] couchbase 1个回答Golang:为什么runtime.GOMAXPROCS限制为256? it技术互联网问答IT行业问题计算机技术编程语言问答 2个回答如何在golang中评估声明和初始化的速记? it技术互联网问答IT行业问题计算机技术编程语言问答 1个回答我可以强制终止goroutine而不必等待它返回吗? selectconcurrencygoroutine 1个回答Go http标准库中的内存泄漏? memory-managementhttpstandard-librarymemory-leaks 1个回答通过并发访问此线程安全吗? concurrencythread-safety 1个回答CakePHP w / jQuery(Javascript / Ajax)简单链接和更新 - 我做错了什么? javascriptajaxphpjquery 1个回答Magento - 加载产品时属性不好? magentophp 1个回答这个js是不是有语法错误?循环里面的东西在运行的时候没有执行,求大佬指点。 ajaxjavascriptbootstrapjquery 2个回答我的$ _FILES在哪里? Ajax上传 ajaxuploadphp 2个回答c++ 语法问题,class Foo : public Observer是啥意思?? c语言开发语言c++ 1个回答ajax获取数据更新table以后,jquery.datatable的js效果失效了该怎么办呀QAQ? html5javascriptbootstrapjqueryajax 2个回答如何设置ajax实时搜索结果的限制? [重复] mysqlphp 1个回答在跟踪数组操作时我做错了什么? arraysphp 2个回答是否可以在RESTful Symfony应用程序中分离Controller和View? restsymfonyapiphp 1个回答如何在PHP的以下场景中将数组元素从关联数组中移除一个? arraysphp 1个回答如何在以下场景中使用foreach循环结构循环关联数组? key-valueforeacharraysphp 2个回答 点击登录 提问题 欢迎建议意见 . 如何写高质量提问和回答? 采纳榜7天 被采纳次数 ProfSnail 25 幻灰龙 19 qq_34124780 154 coagenth 115 规则边缘 116 GoCityPass新加坡曼谷通票 117 cpp_learner 98 Jack_Yang(数据分析及可视化) 99 我不喜欢这个世界 810 天际的海浪 6 加急问题 500 500 基于tensorflow的模型做预测时,cpu占用率过高,如何降低程序的cpu占用率? 100 unity 设置Animation的culling type 导致游戏崩溃 100 java实现下面两个算法 100 ECDSA加密算法中,签名和验证都是需要时间的,那其时间复杂度怎么用椭圆曲线参数如阶或模p来表示呢? 75 数据库只有myd文件没有frm,myi文件,怎么打开呢 51 利用Adams联合matlab仿真求运动学反解问题 50 labview使用datasocket与c/c#程序的通信 50 如何用C语言实现凯撒密码对文本文件(.txt)的读取穷举暴力破解? 50 已知地图GPS坐标点A和坐标点B,获取A点往B点直线走一定距离的坐标点经纬度? 50 用java实现以下算法

本文链接: http://mgline.immuno-online.com/view-692800.html

发布于 : 2021-03-24 阅读(0)
公司介绍
品牌分类
联络我们
服务热线:4000-520-616
(限工作日9:00-18:00)
QQ :1570468124
手机:18915418616