问个 alertview 按钮位置问题

heyli 2012-05-15 09:47:19
我在UIalterView中添加了个 UITextView 用下面的代码对 确定跟取消按钮调位置

for (UIView *Outlet in [alertView subviews]) {
if([Outlet isKindOfClass:[UIButton class]])
{
UIButton* button = (UIButton*)Outlet;
button.frame = CGRectMake(button.frame.origin.x, button.frame.origin.y+100,button.frame.size.width , button.frame.size.height);
}
}

在模拟器上运行 效果正常 但在真机上按钮会给UITextView挡住 请问下要怎么修改 是否是IOS版本的问题?
...全文
297 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
closewbq 2012-05-15
  • 打赏
  • 举报
回复

UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Test:"
message: @"\n\n\n\n\n"
delegate: self
cancelButtonTitle: @"OK"
otherButtonTitles: @"Cancel",nil];
UITextView *textView = [[UITextView alloc] initWithFrame: CGRectMake(12.0, 45.0, 250.0, 120.0)];
textView.layer.cornerRadius = 6;
textView.layer.masksToBounds = YES;
[alert setTransform: CGAffineTransformMakeTranslation(0.0, -100)];
[alert addSubview: textView];
[alert show];

我不知道你要的是不是这种效果
heyli 2012-05-15
  • 打赏
  • 举报
回复
楼上的兄弟 加了没反应 完整的代码如下:

- (void)willPresentAlertView:(UIAlertView *)alertView
{
if([alertView tag] == 5003 || [alertView tag] == 5004)
{
alertView.frame = CGRectMake(alertView.frame.origin.x, alertView.frame.origin.y-80,alertView.frame.size.width , alertView.frame.size.height+100);
UITextView *contentView = [[UITextView alloc]initWithFrame:CGRectMake(alertView.frame.origin.x, alertView.frame.origin.y-115,alertView.frame.size.width-40, 100)];
[contentView setTag:2014];
[alertView addSubview:contentView];
for (UIView *Outlet in [alertView subviews]) {
if([Outlet isKindOfClass:[UIButton class]])
{
UIButton* button = (UIButton*)Outlet;
button.frame = CGRectMake(button.frame.origin.x, button.frame.origin.y+100,button.frame.size.width , button.frame.size.height);
[alertView bringSubviewToFront:button];
}
}
}

}
lure2009 2012-05-15
  • 打赏
  • 举报
回复


for (UIView *Outlet in [alertView subviews]) {
if([Outlet isKindOfClass:[UIButton class]])
{
UIButton* button = (UIButton*)Outlet;
button.frame = CGRectMake(button.frame.origin.x, button.frame.origin.y+100,button.frame.size.width , button.frame.size.height);
//在这加上
[alertView bringSubviewToFront button];
}
}


29,030

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧