我想说明其中含有的UITableView为顶视图,它会显示张贴的用户& 的UITextField用按钮下方将进入评论沿着评论&上添加它到后,我有一个观点在facebook应用程序中看到,当我按下评论按钮时弹出出现。所以我怎么能achhieve在这是最好的方式。我知道我可以通过在动画中添加一个视图在父视图中。但那会导致我添加更多&更多的自定义代码。是否有任何其他方式可以实现这一目标? 如何在iOS中弹出评论框?
回答
如果是为iPad(如右图),尝试创建一个新UIViewController
,并从当前的viewController模态呈现,但在UIModalPresentationStyle
属性设置为UIModalPresentationFormSheet
。
如果设备不是ipad会如何显示在iPhone上 – Techiee
PopUp上的库过多,可以根据需要添加。 最好的是 -
1. https://github.com/jmascia/KLCPopup
和开源的iOS库
2. https://www.cocoacontrols.com/search?q=popup
尝试任何一个,一个巨大的图书馆希望它可以帮助你。
UPDATE编程
添加这些属性: -
@property (strong, nonatomic) UIView *container;
@property (strong, nonatomic) UIView *pop;
@synthesize他们。
SETUP弹出与阴影效应: - 弹出鉴于
-(void)setViewPop{
_container = [[UIView alloc] initWithFrame:self.view.frame];
[self.view addSubview:_container];
//self.backgroundDimmingView = [self buildBackgroundDimmingView];
//[self.container addSubview:self.backgroundDimmingView];
pop = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height , self.view.frame.size.width-80, self.view.frame.size.height/1.5-40)];
pop.backgroundColor = [UIColor orangeColor];
pop.layer.cornerRadius = 10;
UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:pop.bounds];
pop.layer.masksToBounds = NO;
pop.layer.shadowRadius = 5;
pop.layer.shadowColor = [UIColor whiteColor].CGColor;
pop.layer.shadowOffset = CGSizeMake(0.0f, 5.0f);
pop.layer.shadowOpacity = 0.5f;
pop.layer.shadowPath = shadowPath.CGPath;
[self.container addSubview:pop];
[self setUpPop];
pop.center = self.container.center;
}
内容; -
-(void)setUpPop{
self.pop.frame = CGRectMake(0, 0, self.view.frame.size.width-80, self.view.frame.size.height/1.5-40);
UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(90, 10, 100, 20)];
title.textColor = [UIColor whiteColor];
title.textAlignment = NSTextAlignmentCenter;
title.text = @"Choose Date";
[self.pop addSubview:title];
UIButton *cancelbutton = [[UIButton alloc] initWithFrame:CGRectMake(0,self.pop.frame.size.height-40, self.pop.frame.size.width/2, 40)];
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:cancelbutton.bounds byRoundingCorners:(UIRectCornerBottomLeft) cornerRadii:CGSizeMake(10.0, 10.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.view.bounds;
maskLayer.path = maskPath.CGPath;
cancelbutton.layer.mask = maskLayer;
cancelbutton.backgroundColor = [UIColor lightGrayColor];
[cancelbutton setTitle:@"Cancel" forState:UIControlStateNormal];
[cancelbutton addTarget:self
action:@selector(cancelbuttonTapped:)
forControlEvents:UIControlEventTouchUpInside];
[pop addSubview:cancelbutton];
UIButton *confirmbutton = [[UIButton alloc] initWithFrame:CGRectMake(140, self.pop.frame.size.height-40,self.pop.frame.size.width/2, 30)];
UIBezierPath *maskPath1 = [UIBezierPath bezierPathWithRoundedRect:confirmbutton.bounds byRoundingCorners:(UIRectCornerBottomRight) cornerRadii:CGSizeMake(10.0, 10.0)];
CAShapeLayer *maskLayer1 = [[CAShapeLayer alloc] init];
maskLayer1.frame = self.view.bounds;
maskLayer1.path = maskPath1.CGPath;
confirmbutton.layer.mask = maskLayer1;
confirmbutton.backgroundColor = [UIColor orangeColor];
confirmbutton.alpha=0.8f;
[confirmbutton setTitle:@"set Date" forState:UIControlStateNormal];
[pop addSubview:confirmbutton];
}
这是显示视图的动画; -
- (void)showPopUp{
_container.transform = CGAffineTransformMakeScale(0.01, 0.01);
[UIView animateWithDuration:0.5f delay:0 usingSpringWithDamping:0.7f initialSpringVelocity:3.0f options:UIViewAnimationOptionAllowAnimatedContent animations:^{
_container.transform = CGAffineTransformIdentity;
[self setViewPop];
} completion:^(BOOL finished){
// do something once the animation finishes, put it here
}];
}
呼叫-(void)showPopUp
方法点击按钮或在文本框上。作为你的需要。
对于相同的许多第三方库。 你可以看看其中的一些。 http://www.code4app.net/category/popupview
我个人会推荐CTPopOutMenu。 http://www.code4app.net/ios/his-control-is-like-an-UIAlertView-with-button-icon-and-four-basic-layout/54fd4759e24741fd64073341
我已经使用它,它对我来说就像一个魅力。 快乐编码.. :)
- 1. noindex对弹出式评论
- 2. 如何使用Django的评论框架评论评论
- 3. 如何在phpdoc评论中退出phpdoc评论?
- 4. 弹出窗口不动如Facebook评论/像弹出窗口做
- 5. iOS的Facebook的评论添加评论框
- 6. 如何删除Facebook评论框中的评论?
- 7. 如何在dealsea.com上实现评论弹出窗口?
- 8. fb:comments - 如何评论评论
- 9. 从评论框(Facebook评论插件)中删除评论
- 10. 赞按钮html5弹出添加评论
- 11. 评论框出现在点击链接
- 12. iOS中的Facebook评论UIWebView
- 13. TWITTER评论框
- 14. ¿如何在Blogger中的评论列表之前找到评论框?
- 15. 如何样式Facebook赞评论通过链接弹出?
- 16. Facebook Like button评论框,空的评论
- 17. 检索在Facebook评论框中的评论数
- 18. 如何制作评论框如Facebook?
- 19. 失败在评论框
- 20. 博客中的评论框
- 21. 如何批量评论gerrit评论?
- 22. 如何在Facebook fb:comments社交插件中评论评论?
- 23. 如何在iOS中实现弹出对话框
- 24. 如何使回复评论引用评论的ID在论坛
- 25. Facebook喜欢插件,评论框和发送框是弹出窗口下
- 26. 弹出对话框 - iOS
- 27. 边界评论框
- 28. 添加评论框
- 29. 切换评论框
- 30. 评论框行事出人意料
为您的概念使用textview –
我在这里谈论如何显示弹出 – Techiee
您是否在寻找iPhone或iPad的解决方案?对于iPad,有现有的API,您可以在其中以模态方式呈现视图控制器。但iPhone不存在,您需要使用第三方库或您自己的库。 – GoodSp33d