我想實現的是在幾秒鐘內顯示視圖而無需用戶干預。只需按iPhone上的音量控制時出現的鈴聲音量觀點相同的效果:顯示子視圖臨時
我有一個滾動視圖與圖像,圖像中的錄音,聲音開始播放,另一個水龍頭它暫停。我想實現上述效果只是爲了通知動作(顯示播放/暫停圖像)。
我希望我已經完美地解釋了這個問題。
非常感謝您的幫助。
問候 哈維
我想實現的是在幾秒鐘內顯示視圖而無需用戶干預。只需按iPhone上的音量控制時出現的鈴聲音量觀點相同的效果:顯示子視圖臨時
我有一個滾動視圖與圖像,圖像中的錄音,聲音開始播放,另一個水龍頭它暫停。我想實現上述效果只是爲了通知動作(顯示播放/暫停圖像)。
我希望我已經完美地解釋了這個問題。
非常感謝您的幫助。
問候 哈維
假設你有一個從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];
}
你也可以在這裏添加一些動畫,不過這是另外一個問題:)
有你自己嘗試過嗎?你會發現很多人在這裏不會幫助你,除非你先試着自己。 – edc1591 2011-04-11 19:44:25
你可以使一個UIView可見/不可見,其alpha屬性設置爲1/0 – Seega 2011-04-11 19:46:13
首先發布你的代碼比我們可以幫助 – Seega 2011-04-11 19:51:38