【问题标题】:How control volume of device by a progress or slide bar by our application?我们的应用程序如何通过进度条或滑动条控制设备的音量?
【发布时间】:2011-12-13 02:02:08
【问题描述】:

我有一个应用程序,我在其中设置了通知。当通知发出时,声音取决于设备的音量级别。所以我想在我的视图中添加一个进度条或滑块来控制设备的音量。例如,您有一个视图,其中您有滑块/进度条。当你滑动它们时,音量会增加或减少。 如何通过这些工具控制设备的音量?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{ 静态 NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

// Configure the cell...
if(indexPath.row==0)
{
    cell.textLabel.text = @"Vibration";
    UISwitch *switch_vib=[[UISwitch alloc] initWithFrame:CGRectMake(210, 9, 94, 27 )];
    switch_vib.on=YES;
[cell addSubview:switch_vib];

}
else //if(indexPath.row==1)
    cell.textLabel.text = @"Set volumes";
       return cell;

}

提前谢谢...

【问题讨论】:

    标签: iphone volume uislider uiprogressview uidevice


    【解决方案1】:

    您只能使用MPVolumeView 让用户控制音量。您需要做的就是将该视图添加到您的视图层次结构中,它负责设置音量并反映硬件按钮所做的任何音量更改。您可以遍历其子视图以找到滑块以适应其设计。 (故意)没有公开方式以编程方式更改音量。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-15
      • 1970-01-01
      • 2011-09-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-09
      • 1970-01-01
      相关资源
      最近更新 更多