2010-02-19 15 views
9

alt text http://28.media.tumblr.com/tumblr_ky3ezghsar1qzzxzzo1_400.jpgUIActivityIndicatorView या इसी तरह

किसी को मुझे बताओ कि इस तरह के लोड हो रहा है संदेश प्राप्त करने के लिए कर सकते हैं? क्या यह UIActivityIndicatorView की कुछ भिन्नता है? धन्यवाद पीटर

+7

क्या रंग योजना ... – kennytm

उत्तर

1

कताई चक्र निश्चित रूप से एक UIActivityIndicatorView है। "लोड हो रहा है ..." टेक्स्ट एक उइलाबेल है, आयत एक छवि हो सकती है या गोलाकार कोनों (कैलियर के माध्यम से) के साथ एक यूआईवीव हो सकती है। बाकी संदेश के बारे में कोई सवाल? टी

1

यदि आप मौजूदा समाधान की तलाश में हैं तो आप three20 लाइब्रेरी का उपयोग कर सकते हैं - उन्होंने TTActivityLabel कक्षा में इस कार्यक्षमता को लागू किया है।

22

कुछ अपने कस्टम subclassed UIView के अपने initWithFrame में निम्न के समान:

_hudView = [[UIView alloc] initWithFrame:CGRectMake(75, 155, 170, 170)]; 
    _hudView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5]; 
    _hudView.clipsToBounds = YES; 
    _hudView.layer.cornerRadius = 10.0; 

    _activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; 
    _activityIndicatorView.frame = CGRectMake(65, 40, _activityIndicatorView.bounds.size.width, _activityIndicatorView.bounds.size.height); 
    [_hudView addSubview:_activityIndicatorView]; 
    [_activityIndicatorView startAnimating]; 

    _captionLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 115, 130, 22)]; 
    _captionLabel.backgroundColor = [UIColor clearColor]; 
    _captionLabel.textColor = [UIColor whiteColor]; 
    _captionLabel.adjustsFontSizeToFitWidth = YES; 
    _captionLabel.textAlignment = NSTextAlignmentCenter; 
    _captionLabel.text = @"Loading..."; 
    [_hudView addSubview:_captionLabel]; 

    [self addSubview:_hudView]; 
+0

बहुत बढ़िया! समाधान के लिए धन्यवाद !! –

0

करने का मेरा तरीका यह बहुत सरल और मेरे लिए चिकनी काम करता है;

अपने "MainWindow.xib" जो एप्लिकेशन के जीवनकाल के माध्यम से सभी उपलब्ध है अंदर इंटरफ़ेस बिल्डर में अपने लोड हो रहा है डिज़ाइन दृश्य (बेशक आप एक, प्रकार और विकल्प की संरचना पर निर्भर है तो) आप तो एक नहीं है, बस इसे अपने दृश्य में डिज़ाइन करें, जहां आप अपने मुख्य ऐपडिलेगेट से प्रोग्रामर को एक पॉइंटर ले सकते हैं (डिज़ाइन पसंद के अपने स्वाद का उपयोग करें, लेकिन मेनविंडो.एक्सिब का उपयोग करना सबसे आसान है)

फिर इस दृश्य को एक चर आपका YourApp क्लास जो आपके कुख्यात ऐप प्रतिनिधि वर्ग है।

Let the designed View map to an IBOutlet named "loading" 
inside your app delegate class "YourApp" 
by using the Interface Builder's wiring 

फिर, कुछ वर्ग में निम्नलिखित कार्य डाल दिया और उन्हें लोड हो रहा है दृश्य आपको कुछ महंगे सामान को चलाने से पहले दिखाने के लिए

यह आनंद लें;

+(void)showLoading { 
    YourApp* app = (YourApp*)[[UIApplication sharedApplication] delegate]; 
    [UIApplication sharedApplication].networkActivityIndicatorVisible = true; 
    [app.loading removeFromSuperview]; 
    [app.window addSubview:app.loading]; 
    app.loading.alpha = 0.0; 
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:0.50]; 
    app.loading.alpha = 0.8; 
    [UIView commitAnimations]; 
} 

और यह कॉलबैक से इसे हटाने के लिए या महंगा कार्य पूरा होने पर जो भी हो जाता है;

+(void)hideLoading { 
    [UIApplication sharedApplication].networkActivityIndicatorVisible = false; 
    YourApp* app = (YourApp*)[[UIApplication sharedApplication] delegate]; 
    [app.loading removeFromSuperview]; 
} 

पुनश्च: और हाँ मैं उपयोग शून्य, सच है, नहीं के बराबर के बजाय झूठे हां, नहीं स्पष्ट कारणों के लिए ...

आशा है कि यह मदद करता है, का आनंद लें ...

1

यह देख ----

- (void)viewDidLoad { 
    [super viewDidLoad]; 

     // [self ShowMsg]; 

    //-----------------checking version of IOS ----------------------------------- 
    CGFloat ver = [[[UIDevice currentDevice]systemVersion]floatValue]; 
    NSString *str = [NSString stringWithFormat:@"%f",ver]; 
    NSLog(@"%@",str); 
    NSArray *arr = [str componentsSeparatedByString:@"."]; 
    strVerChk = [arr objectAtIndex:0]; 
    NSLog(@"%@",strVerChk); 
    [strVerChk retain]; 

    NSInteger verChk = [[NSString stringWithFormat:@"%@",strVerChk]intValue]; 
    NSLog(@"integer %d",verChk); 
    if (verChk < 5) { 
     imag = [UIImage imageNamed:@"WaitScreen.png"]; 
    } 
    else 
    { 
     imag = [UIImage imageNamed:@"WaitScreen_5.png"]; 
    } 
    Lblmsg = [[UILabel alloc]init]; 
       //WithFrame:CGRectMake(10, 10, 100, 30)]; 
    Lblmsg.backgroundColor = [UIColor clearColor]; 
    Lblmsg.textColor = [UIColor whiteColor]; 
    Lblmsg.text = @"  Please Wait...."; 

    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
    { 
     [Lblmsg setFont:[UIFont fontWithName:@"Arial" size:16]]; 
    }else 
    { 
     [Lblmsg setFont:[UIFont fontWithName:@"Arial" size:12]]; 
    } 

    Lblmsg.textAlignment = UITextAlignmentCenter; 
    activityInd = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; 
    // [activityInd startAnimating]; 

    imageview = [[UIImageView alloc]initWithImage:imag]; 
    [imageview addSubview:Lblmsg]; 
    [imageview addSubview:activityInd]; 
    [self.view addSubview:imageview]; 
    self.view.backgroundColor = [UIColor clearColor]; 

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) 
    { 

     // self.interfaceOrientation = [UIApplication sharedApplication].statusBarOrientation 
     UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; 
     if(orientation == UIInterfaceOrientationPortrait ||orientation == UIInterfaceOrientationPortraitUpsideDown) 
     { 
      self.view.frame = CGRectMake(0, 0, 320, 480); 
      imageview.frame = CGRectMake(100, 130, 120, 80); 
     } 
     else{ 
      self.view.frame = CGRectMake(0, 0, 480, 320); 
      imageview.frame = CGRectMake(180, 70, 120, 80); 

     } 
     Lblmsg.frame = CGRectMake(0, 45, 120, 40); 

     NSInteger verChk = [[NSString stringWithFormat:@"%@",strVerChk]intValue]; 
     NSLog(@"integer %d",verChk); 
     if (verChk < 5) { 
      activityInd.frame = CGRectMake(41, 9, 28, 28); 
     } 
     else 
     { 
      activityInd.frame = CGRectMake(41, 9, 28, 28); 
     } 
     [activityInd startAnimating]; 
    } 
    else{ 

     UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; 
     if(orientation == UIInterfaceOrientationPortrait ||orientation == UIInterfaceOrientationPortraitUpsideDown) 
     { 
      self.view.frame = CGRectMake(0, 0, 768, 1024); 
      imageview.frame = CGRectMake(274, 330, 210, 160); 
      Lblmsg.frame = CGRectMake(10, 115, 190, 30); 
      NSInteger verChk = [[NSString stringWithFormat:@"%@",strVerChk]intValue]; 
      NSLog(@"integer %d",verChk); 
      if (verChk < 5) {   
      activityInd.frame = CGRectMake(71, 20, 52, 52); 
      } 
      else 
      { 
       activityInd.frame = CGRectMake(71, 20, 49, 49); 
      } 
      [activityInd startAnimating]; 

     } 
     else{ 
      self.view.frame = CGRectMake(0, 0, 1024, 768); 
      imageview.frame = CGRectMake(390, 264, 200, 150); 
      Lblmsg.frame = CGRectMake(10, 115, 180, 30); 

      NSInteger verChk = [[NSString stringWithFormat:@"%@",strVerChk]intValue]; 
      NSLog(@"integer %d",verChk); 
      if (verChk < 5) {   
       activityInd.frame = CGRectMake(68, 17, 52, 52); 
      } 
      else 
      { 
       activityInd.frame = CGRectMake(68, 17, 49, 49); 
      } 
      [activityInd startAnimating]; 

     } 


    } 


    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(didRotate) 
               name:@"UIDeviceOrientationDidChangeNotification" object:nil]; 

} 
-(void)didRotate{ 

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) 
    { 

     // self.interfaceOrientation = [UIApplication sharedApplication].statusBarOrientation 
     UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; 
     if(orientation == UIInterfaceOrientationPortrait ||orientation == UIInterfaceOrientationPortraitUpsideDown) 
     { 
      self.view.frame = CGRectMake(0, 0, 320, 480); 
      imageview.frame = CGRectMake(100, 130, 120, 80); 
      //Lblmsg.frame = CGRectMake(0, 40, 120, 30); 
      //activityInd.frame = CGRectMake(20, 10, 80, 30); 


     } 
     else{ 
      self.view.frame = CGRectMake(0, 0, 480, 320); 
      imageview.frame = CGRectMake(180, 70, 120, 80); 

      //activityInd.frame = CGRectMake(20, 10, 80, 30); 
      //activityInd.frame = CGRectMake(50, 15, 10, 10); 
      //[activityInd startAnimating]; 


     } 
     Lblmsg.frame = CGRectMake(0, 45, 120, 40); 
     NSInteger verChk = [[NSString stringWithFormat:@"%@",strVerChk]intValue]; 
     NSLog(@"integer %d",verChk); 
     if (verChk < 5) { 
      activityInd.frame = CGRectMake(41, 9, 28, 28); 
     } 
     else 
     { 
      activityInd.frame = CGRectMake(41, 9, 28, 28); 
     } 

     [activityInd startAnimating]; 
    } 
    else{ 

     UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; 
     if(orientation == UIInterfaceOrientationPortrait ||orientation == UIInterfaceOrientationPortraitUpsideDown) 
     { 
      self.view.frame = CGRectMake(0, 0, 768, 1024); 
      imageview.frame = CGRectMake(274, 330, 210, 160); 
      Lblmsg.frame = CGRectMake(10, 115, 190, 30); 
      NSInteger verChk = [[NSString stringWithFormat:@"%@",strVerChk]intValue]; 
      NSLog(@"integer %d",verChk); 
      if (verChk < 5) {   
       activityInd.frame = CGRectMake(71, 20, 52, 52); 
      } 
      else 
      { 
       activityInd.frame = CGRectMake(71, 20, 49, 49); 
      } 
      [activityInd startAnimating]; 


     } 
     else{ 
      self.view.frame = CGRectMake(0, 0, 1024, 768); 
      imageview.frame = CGRectMake(390, 264, 200, 150); 
      Lblmsg.frame = CGRectMake(10, 115, 180, 30); 
      NSInteger verChk = [[NSString stringWithFormat:@"%@",strVerChk]intValue]; 
      NSLog(@"integer %d",verChk); 
      if (verChk < 5) {   
       activityInd.frame = CGRectMake(68, 17, 52, 52); 
      } 
      else 
      { 
       activityInd.frame = CGRectMake(68, 17, 49, 49); 
      } 
      [activityInd startAnimating]; 


     } 


    } 


} 
+0

thanx आप मेरा दिन बचाओ। –

0

आप एक अलग एनीमेशन चाहता था, मैं एक कस्टम UIView (Loader Animation) बनाया है जो आप UIActivity का एक उपवर्ग में लोड करने के लिए कर सकता है।

संबंधित मुद्दे