iphone - 将 UIPickerView 添加到 UIActionSheet(底部的按钮)
<p><p>我想要</p>
<ol>
<li>显示选择器 View (向上滑动)</li>
<li>在可见时停用背景</li>
<li>在底部(而不是顶部)显示 (UIActionSheet) 按钮</li>
</ol>
<p>起初在我看来这是一个简单的解决方案,因为您可以在网络上的任何地方找到将选择器 View 添加到操作表的代码,但所有解决方案都将按钮放在顶部,<strong>我需要将按钮放在操作表的底部(对齐?)</strong>。 </p>
<p>这可能吗?我想如果我看一下:<a href="http://s3.amazonaws.com/files.posterous.com/app-incubator/mplGAlcfmHlCwDnjcpqtrfyIqsjvafGjvdnJcBvrGnzJgkkElpFHoooroojE/media_httpdldropboxco_mAbpk.png.scaled500.png?AWSAccessKeyId=AKIAJFZAE65UYRT34AOQ&Expires=1366476962&Signature=Ub/dgv/2gghKSP%2b8SA1gpJcYN1s=" rel="noreferrer noopener nofollow">Example</a> </p>
<p>问候</p>
<p>杰文</p>
<p><strong>已编辑(我的解决方案基于 coded dads 解决方案)</strong></p>
<pre><code>UIActionSheet *actionSheet = [ initWithTitle:nil
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
;
CGRect pickerFrame = CGRectMake(0, 0, 0, 0);
UIPickerView *pickerView = [initWithFrame:pickerFrame];
pickerView.showsSelectionIndicator = YES;
pickerView.dataSource = self;
pickerView.delegate = self;
UISegmentedControl *backButton =[ initWithItems:] ;
;
backButton.tintColor = ;
backButton.segmentedControlStyle = UISegmentedControlStyleBar;
;
backButton.frame = CGRectMake(20.0, 220.0, 280.0, 40.0);
UISegmentedControl *acceptButton =[ initWithItems:] ;
;
acceptButton.tintColor = ;
acceptButton.segmentedControlStyle = UISegmentedControlStyleBar;
acceptButton.frame = CGRectMake(20.0, 280.0, 280.0, 40.0);
;
;
;
keyWindow]];
;
</code></pre>
<p>...然后只需应用 iPhone 5/iphone 4 相关 View 大小约束</p>
<p><strong>编辑 2:</strong>
只是另一个提示!最初我想使用标准的 Actionsheet,但不想将pickerview 放在底部。我没有找到如何移动按钮的方法。显然它非常简单:<a href="https://stackoverflow.com/questions/11051512/add-uiview-as-subview-on-uiactionsheet" rel="noreferrer noopener nofollow">Add UIView as subView on UIActionSheet</a>很高兴知道;)</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>你有两种可能:</p>
<p><strong>选项 1:大调整。</strong></p>
<p>ActionSheet 以初始化期间定义的顺序显示按钮。所以在顶部放置一些虚拟按钮,取消将是唯一可见的,所有其他按钮将被选择器 View 隐藏。代码<em>(otherButtonTitles 的警告调整)</em>:</p>
<pre><code>UIActionSheet *menu = [ initWithTitle:@"Actionsheet"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"1", @"2", @"3", @"4", nil];
UIPickerView *pickerView = [ init];
pickerView.delegate = self;
pickerView.dataSource = self;
;
;
;
CGRect pickerRect = pickerView.bounds;
pickerRect.origin.y = 35;
pickerView.frame = pickerRect;
</code></pre>
<p><strong>选项2:自制</strong> </p>
<pre><code>menu = [ initWithTitle:@"Actionsheet"
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
UIPickerView *pickerView = [ init];
pickerView.delegate = self;
pickerView.dataSource = self;
CGRect pickerRect = pickerView.bounds;
pickerRect.origin.y = 35;
pickerView.frame = pickerRect;
UIButton *startbtn = ;
startbtn.frame = CGRectMake(80,230, 170, 73);
forState:UIControlStateNormal];
;
;
;
;
;
</code></pre>
<p>检查选项 2 的按钮是否应该在操作表上,除非点击不会被分派(dispatch)到选择器方法。</p></p>
<p style="font-size: 20px;">关于iphone - 将 UIPickerView 添加到 UIActionSheet(底部的按钮),我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/16122487/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/16122487/
</a>
</p>
页:
[1]