2011-04-11 63 views
0

我想实现的是在几秒钟内显示视图而无需用户干预。只需按iPhone上的音量控制时出现的铃声音量观点相同的效果:显示子视图临时

ringer

我有一个滚动视图与图像,图像中的录音,声音开始播放,另一个水龙头它暂停。我想实现上述效果只是为了通知动作(显示播放/暂停图像)。

我希望我已经完美地解释了这个问题。

非常感谢您的帮助。

问候 哈维

+1

有你自己尝试过吗?你会发现很多人在这里不会帮助你,除非你先试着自己。 – edc1591 2011-04-11 19:44:25

+0

你可以使一个UIView可见/不可见,其alpha属性设置为1/0 – Seega 2011-04-11 19:46:13

+1

首先发布你的代码比我们可以帮助 – Seega 2011-04-11 19:51:38

回答

4

假设你有一个从UIViewController继承了一些类。您可以使用下面的代码:

const int myViewTag = 10001; 
const int myInterval = 1; // define the time you want your view to be visible 

- (void)someAction { 
    //this could be your `IBAction` implementation 
    [self showMyView]; 
    [NSTimer scheduledTimerWithTimeInterval:myInterval 
            target:self 
            selector:@selector(hideMyView) 
            userInfo:nil 
            repeats:NO]; 
} 


- (void) showMyView { 
    //you can also use here a view that was declared as instance var 
    UIView *myView = [[[UIView alloc] initWithFrame:CGRectMake(100, 100, 120, 120)] autorelease]; 

    myView.tag = myViewTag; 
    [self.view addSubview:myView]; 
} 

- (void) hideMyView { 
    //this is a selector that called automatically after time interval finished 
    [[self.view viewWithTag:myViewTag] removeFromSuperview]; 
} 

你也可以在这里添加一些动画,不过这是另外一个问题:)

+0

如何删除一个编辑?我偶然发现了一个。 – 2011-04-11 20:00:08

+0

@Black Frog,别担心,我刚刚拒绝了 – knuku 2011-04-11 20:02:35

+0

谢谢@NR4TR,这就是我试图实现的 – monti 2011-04-12 07:38:12