2011-10-22 28 views
0

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

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

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

}

在此先感谢...

回答

0

您只能使用MPVolumeView让用户控制音量。您只需将该视图添加到视图层次结构中,即可设置音量并反映由硬件按钮完成的任何音量更改。您可以走其子视图来查找滑块以适应其设计。有(故意)没有公开的方式来以编程方式更改音量。

相关问题