0

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

- (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;

}

提前致谢...

4

1 回答 1

0

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

于 2011-10-22T08:34:42.557 回答