私信 访问主页
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条回答私信 访问主页
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 :)
点赞 评论 复制链接分享私信 访问主页
Recently started using MGBox2. Loving it, thank you! :)
1 vote for the touch down event handling and highlight.
点赞 评论 复制链接分享私信 访问主页
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.
点赞 评论 复制链接分享私信 访问主页
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.
点赞 评论 复制链接分享私信 访问主页
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.
点赞 评论 复制链接分享私信 访问主页
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.
点赞 评论 复制链接分享私信 访问主页
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.
点赞 评论 复制链接分享私信 访问主页
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
点赞 评论 复制链接分享私信 访问主页
No go there... but I ll keep trying and will report back when I have something working! Thanks for your help.
点赞 评论 复制链接分享私信 访问主页
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.
点赞 评论 复制链接分享私信 访问主页
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 :)
点赞 评论 复制链接分享私信 访问主页
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天 被采纳次数本文链接: http://mgline.immuno-online.com/view-692800.html