gpt4 book ai didi

iphone - iPhone滑盖 View Controller 可用于音频播放器控件吗?

转载 作者:行者123 更新时间:2023-12-03 00:21:49 26 4
gpt4 key购买 nike

我有一个按下按钮时会播放的简短音频剪辑。我想从底部创建一个向上滑动的 Controller ,其中包含一个暂停/播放按钮和一个显示音频长度的滑动条。我还希望 Controller 可见时, Controller 后面的 View 仍可滚动。我相信这会排除使用UIAlertView或UIActionSheetView的原因,因为两者都会导致下面的 View 保持静态。实现此目的的最佳方法是什么?

编辑:我在这里找到了一个有用的教程: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

最佳答案

“上滑 Controller ”是什么意思?只是从底部向上滑动的 View ?如果是这样,您可以只创建一个带有按钮的UIView并对其进行动画处理。对于动画,您可以使用UIView beginAnimations:context:commitAnimations

关于iphone - iPhone滑盖 View Controller 可用于音频播放器控件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4178813/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com