2011-08-06 6 views
0

을 수행해야합니다은 내가 이런 짓을 했을까 아이폰 OS에서는되는 SplashScreen

다음
splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 768, 1024)]; 
splashView.image = [UIImage imageNamed:@"Default.png"]; 
[window addSubview:splashView]; 
[window bringSubviewToFront:splashView]; 

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:3.5]; 
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:window cache:YES]; 
[UIView setAnimationDelegate:self]; 
[UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)]; 
splashView.alpha = 0.0; 
splashView.frame = CGRectMake(-60, -60, 900, 1200); 
[UIView commitAnimations]; 

그리고 "푸시"보기 컨트롤러에 이동합니다.

나는 다양한 예제와 튜토리얼을 살펴 보았다 및에 필요한 것을 코드에 핸들을 얻을 수 없다 (? 액션)

  • 그것이
  • 다른 전망을 페이드 아웃

    1. 표시하려면되는 SplashScreen을 표시됩니다.

    일부는이 내용을 게시했지만 주석 처리 된 코드는 오류가 발생합니다. 나는 뭔가를 놓치고 있어야합니다.

  • +0

    . 사용자가 무시하거나 약간 성가 시게하는 기능입니다. – kwatford

    +0

    많은 예가 있습니다. http://stackoverflow.com/questions/6918430/splash-screenhow-to-show-an-image-in-full-screen/6918484#6918484 –

    답변

    1
    public class SplashScreen extends Activity { 
    protected boolean _active = true; 
    protected int _splashTime = 3000; 
    
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
    
        this.requestWindowFeature(Window.FEATURE_NO_TITLE); 
        setContentView(R.layout.splash); 
    
        // thread for displaying the SplashScreen 
        Thread splashTread = new Thread() { 
         @Override 
         public void run() { 
          try { 
           int waited = 0; 
           while (_active && (waited < _splashTime)) { 
            sleep(100); 
            if (_active) { 
             waited += 100; 
            } 
           } 
          } catch (InterruptedException e) { 
           // do nothing 
          } finally { 
           finish(); 
           startActivity(new Intent(
             "com.android.NextActivity")); 
          } 
         } 
        }; 
        splashTread.start(); 
    } 
    
    @Override 
    public boolean onTouchEvent(MotionEvent event) { 
        if (event.getAction() == MotionEvent.ACTION_DOWN) { 
         _active = false; 
        } 
        return true; 
    } 
    

    }

    및 splash.xml : 아무도 스플래시 화면을 좋아한다 제안하고 당신이 정말로 하나를 수행 귀찮게하지 것을 제외하고 내가 거기에 당신을 도울 수

    <?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 
    <ImageView android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:src="@drawable/your_image_here" /> 
    </LinearLayout> 
    
    +0

    답변 해 주셔서 감사합니다. 그러나 내 무지를 용서하십시오. . 프로젝트에 splash.xml을 어디에 넣어야하는지 알지만 다른 코드가 어디에 속해 있는지 잘 모르겠습니다. – user3160965

    +0

    'splash.xml ->/layout', 코드 ->'SplashScreen.java', 파일을 만들어야합니다. 그리고, 물론 당신이 '로 매니페스트에 활동을 선언해야 <: 이름 = "로 SplashScreen" \t \t \t 안드로이드 : 활동 \t \t \t 안드로이드 라벨 = "@ 문자열/APP_NAME을 (를)"/>' –

    관련 문제