У меня есть короткий аудиоклип, который воспроизводится при нажатии кнопки. Я хочу создать понижающий контроллер снизу, содержащий кнопку паузы/воспроизведения и ползунок, отображающий длину звука. Я также хочу, чтобы представление за контроллером оставалось прокручиваемым, пока контроллер виден. Я считаю, что это исключает использование UIAlertView или UIActionSheetView, так как оба они остаются неподвижными. Каков наилучший способ реализации этого?Контроллер просмотра слайдов iPhone для управления аудиоплеером?
EDIT: я нашел полезный учебник здесь: http://iosdevelopertips.com/user-interface/sliding-views-on-and-off-screen-creating-a-reusable-sliding-message-widget.html
, и я был в состоянии изменить это, чтобы получить что-то, что я хочу. Однако, если я хотел бы оживить, используя файл nib, где/как я мог бы это назвать?
#import "SlidingMessageController.h"
@interface SlidingMessageController(private)
- (void)hideMsg;
@end
@implementation SlidingMessageController
#pragma mark -
#pragma mark Private Methods
- (void)hideMsg;
{
// Slide the view off screen
CGRect frame = self.frame;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:.75];
frame.origin.y = 480;
frame.origin.x = 0;
self.frame = frame;
//to autorelease the Msg, define stop selector
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView commitAnimations];
}
- (void)animationDidStop:(NSString*)animationID finished:(BOOL)finished context:(void *)context
{
[self removeFromSuperview];
[self release];
}
#pragma mark -
#pragma mark Initialization
- (id)initWithDirection:(int)dir;
//- (id)initWithTitle:(NSString *)title message:(NSString *)msg
{
if (self = [super init])
{
//Switch direction based on slideDirection konstant
switch (dir) {
case kSlideUp: //slideup
// Notice the view y coordinate is offscreen (480)
// This hides the view
// What should I be doing here if I want to get the nib file???
self.frame = CGRectMake(0,480,320, 90);
[self setBackgroundColor:[UIColor blackColor]];
[self setAlpha:.87];
newY = 380;
newX = 0;
myDir = 0;
break;
default:
break;
}
}
return self;
}
#pragma mark -
#pragma mark Message Handling
- (void)showMsgWithDelay:(int)delay
{
// UIView *view = self.view;
CGRect frame = self.frame;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:.75];
// Slide up based on y axis
// A better solution over a hard-coded value would be to
// determine the size of the title and msg labels and
// set this value accordingly
frame.origin.y = newY;
frame.origin.x = newX;
self.frame = frame;
[UIView commitAnimations];
// Hide the view after the requested delay
[self performSelector:@selector(hideMsg) withObject:nil afterDelay:delay];
}
#pragma mark -
#pragma mark Cleanup
- (void)dealloc
{
if ([self superview])
[self removeFromSuperview];
[super dealloc];
}
@end
Я рекомендую не делать этого. Это будет запутанный интерфейс и будет сложно управлять программным путем. Существует причина, что листы действий являются модальными. – TechZen
Если выполнено хорошо, это может, безусловно, работать imho. Предположим, вы нажмете кнопку, чтобы начать воспроизведение аудиофайла. Элементы управления затем отображаются в нижней части экрана, чтобы вы могли играть/приостанавливать и т. Д. В любое время. Не думайте, что это путает пользователей. Опять же, если все сделано правильно, конечно. – Rengers
Я думал о чем-то подобном приложении NPR Music. Это сделано довольно хорошо, и я думаю, что это хорошее решение для того, что я ищу. – alittlelost